- Response.Redirect()
- Server.Transfer()
First approach(easiest way):
Just use the OnClientClick event of the button.
<asp:Button ID="btnHome" runat="Server" CssClass="button" Text="Go home"
OnClick="btnHome_Click" OnClientClick="aspnetForm.target ='_blank';"/>
protected void btnHome_Click(object sender, EventArgs e)
{
Response.Redirect("Home.aspx");
}
If you want to access the form inside the Master page to Child page level
Button1.OnClientClick=string.Format("{0}.target='_blank';",((HtmlForm)Page.Master.FindControl("form1")).ClientID);
This code will find the controls collection and find your form and allow you to get access to the client id so you can be sure you have proper naming of it for the JavaScript to function correctly. Make sure you replace "form1" with whatever you have your parent form id="name" set to inside your Master’s page markup.
For multiple buttons on a single page and only want a specific button to launch into a new window.
<asp:Button ID="btnHomePage" runat="Server" CssClass="button" Text="Your home"
OnClick="btnHomePage_Click" OnClientClick="aspnetForm.target ='_self';"/>
protected void btnHomePage_Click(object sender, EventArgs e)
{
//Do normal code for postback
}
For more details.visits
In next post I will share with you another approach to open new window using response.redirect() insha Allah.