woodykiddy
woodykiddy

Reputation: 6455

How to open ASP page in a new tab/window?

I know that the HTML anchor tag has an attribute called target, which will open a new page in a new window/tab if we set target='_blank'. It should work well with static HTML pages.

However, when we submitting a form by clicking the submit button on an ASP page, I find that the result page normally will be loaded into the same tab/window.

So my question is: are we able to load page into a new tab/window when user clicks submit button?

Thanks.

EDIT: Looks like <form target='blank'> is the answer although its said to be deprecated according to w3schools website. :)

Upvotes: 1

Views: 10490

Answers (4)

Himanshu
Himanshu

Reputation: 716

You have two methods for redirecting the page to new tab in asp

1) Make an onclientclick event of Button and on code behind of Button Click write the following code:-

button.OnClientClick = "aspnetForm.target='_blank'"; Response.Redirect("yourpage.aspx");

2)You can also use javascript

 button.Attributes.Add("onclick", "window.open('yourpage.aspx');return false;");

Both the method will redirect your page to new tab on clicking the button.

Upvotes: 0

Ravan Scafi
Ravan Scafi

Reputation: 6392

Form's target shold work.

<form target="_blank" ...></form>

From here (have you searched?)

Upvotes: 4

Matt
Matt

Reputation: 4200

Try this out..

Response.Redirect to new window

Upvotes: 1

Thom Smith
Thom Smith

Reputation: 14086

Just like a link:

<form target='_blank'>

No need to do anything on the ASP side of things. Of course, as with all pop-ups, this is subject to browser settings.

Upvotes: 4

Related Questions