Discover innovative solutions, best practices, and cutting-edge technologies in enterprise architecture
Thursday, September 3, 2009
Open New Tab/Window (Response.Redirect open in new web page)
Hello Friends,
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 client script 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”);
}
OR
Response.Write( "<script> window.open( 'pageName.aspx' ); </script>");
Response.End();
// Here we can write javascript code to open new tab
--------------------
Happy programming.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment