1

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. :)

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
woodykiddy
  • 6,074
  • 16
  • 59
  • 100

4 Answers4

4

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.

Thom Smith
  • 13,916
  • 6
  • 45
  • 91
  • yeah I just found that out on w3schools [http://www.w3schools.com/tags/tag_form.asp], but it says the attribute target is deprecated. – woodykiddy Jun 28 '11 at 03:51
  • 2
    W3Schools seems to be in error. The target attribute in general is theoretically available only with a Loose or Transitional doctype, but in practice, I believe that every browser will support it even if you declare Strict. – Thom Smith Jun 28 '11 at 03:55
  • 3
    Ignore w3Schools, w3c spec for forms includes the target attribute as part of html5: http://www.w3.org/TR/html5/forms.html – Jon P Jun 28 '11 at 03:59
4

Form's target shold work.

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

From here (have you searched?)

Community
  • 1
  • 1
Ravan Scafi
  • 6,382
  • 2
  • 24
  • 32
1

Try this out..

Response.Redirect to new window

Community
  • 1
  • 1
Matt
  • 4,140
  • 9
  • 40
  • 64
0

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.

Himanshu
  • 706
  • 6
  • 27