Here I am going to explain how to open new tab/window on Button click using asp.net.
A week ago, i have to implement that code. I have option to use javascipt windows.open to open new tab.
But I have to insert or update some database entry. Yeah i know that there is another way to use clientscipt in code behind to achieve this.
But in its simplest form, following code open new tab/window.
A week ago, i have to implement that code. I have option to use javascipt windows.open to open new tab.
But I have to insert or update some database entry. Yeah i know that there is another way to use clientscipt in code behind to achieve this.
But in its simplest form, following code open new tab/window.
<asp:Button ID=”btnNewEntry” runat=”Server” CssClass=”button” Text=”New Entry” OnClick=”btnNewEntry_Click” OnClientClick=”aspnetForm.target =’_blank’;”/> // aspnetForm.target =’_blank’ will add handler to open new tab
protected void btnNewEntry_Click(object sender, EventArgs e)
{
Response.Redirect(”New.aspx”);
}aspnetForm is the form name, it can be different in some pages, so be sure to check the viewsource of the page you are working on.
Cheers
Cheers


8:21 AM
Anoop ms
12 comments:
Thanks for the info. Worked for me.
you rock it really2x works thank you so much!!!!
from: http://infotechnolozyx.blogspot.com/
not working for me
not working for me
slight change might work for every one
replace
OnClientClick=”aspnetForm.target =’_blank’;”
with
OnClientClick="document.getElementById('form1').target ='_blank';"
"form1" is the id of the form tag
OnClientClick="document.getElementById('form1').target ='_blank';"
Works for me ! Thanks !
It works.. But not only for the particular control.. If i click some other controls in the same page, after click this control, That control also open a new tab.. Plz check that..
OnClientClick="document.getElementById('form1').target ='_blank';"
Works for me ! Thanks !
working fine., thanx
its working
asp:Button ID=”btnNewEntry” runat=”Server” CssClass=”button” Text=”New Entry” OnClick=”btnNewEntry_Click” OnClientClick=”target =’_blank’;”/>
its working
Post a Comment