Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch another aspx web page upon button click?

I have an asp.net application, where the user would click a button and launch another page (within the same application). The issue I am facing is that the original page and the newly launched page should both be launched.

I tried response.redirect, but that tends to unload the original page.

Any suggestions?

like image 805
Csharp Avatar asked Sep 09 '11 18:09

Csharp


People also ask

How do you call an ASPX page from another ASPX page?

Transfer("default. aspx"); // At URL You will not Get the default page as what you are redirecting to. example : If you are logged in Login page then you want to redirect to default page ,then you can use both the above mentioned methods.

How to go from one page to another in ASP net c#?

Redirect method redirects a request to a new URL and specifies the new URL while the Server. Transfer method for the current request, terminates execution of the current page and starts execution of a new page using the specified URL path of the page. Both Response. Redirect and Server.


2 Answers

This button post to the current page while at the same time opens OtherPage.aspx in a new browser window. I think this is what you mean with ...the original page and the newly launched page should both be launched.

<asp:Button ID="myBtn" runat="server" Text="Click me" 
     onclick="myBtn_Click" OnClientClick="window.open('OtherPage.aspx', 'OtherPage');" />
like image 66
Claudio Redi Avatar answered Nov 13 '22 09:11

Claudio Redi


Edited and fixed (thanks to Shredder)

If you mean you want to open a new tab, try the below:

protected void Page_Load(object sender, EventArgs e)
{
    this.Form.Target = "_blank";
}

protected void Button1_Click(object sender, EventArgs e)
{

    Response.Redirect("Otherpage.aspx");
}

This will keep the original page to stay open and cause the redirects on the current page to affect the new tab only.

-J

like image 32
KreepN Avatar answered Nov 13 '22 08:11

KreepN