c# - Open New Tab in ASP.NET web page -


after clicking on asp.net button, redirects correct website on same tab, not in new tab, need do. after clicking button twice, redirects website in new tab. don't know what's wrong code!

the asp.net button control looks this:

<asp:imagebutton id="imagebutton1" runat="server" imageurl="../images/neu.png" onclick="new_btn_click" /> 

and code run this:

protected void new_btn_click(object sender, eventargs e) {     imagebutton1.attributes.add("onclick", "window.open('new_model_epk.aspx');return false;");    } 

what you're describing expect. javascript isn't run until second time because hasn't been added until after click button first time. don't use c#; use this:

<asp:imagebutton id="imagebutton1" runat="server" imageurl="../images/neu.png" onclientclick="window.open('new_model_epk.aspx');return false;" /> 

any javascript in onclientclick attribute run right away when click element, c# code unnecessary.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -