user187707
user187707

Reputation:

ASP Net - How to open up a form in a new window in ASP.NET

I am working on ASP.net using VB.net. I need to load a page in a new window on button click. Can someone suggest the code for the same.

Upvotes: 0

Views: 7394

Answers (3)

o.k.w
o.k.w

Reputation: 25790

If you do not need a postback to the new window, then this:

<input type="button" value="buttonName" onclick="window.open('[page]')" />

OR

<asp:button text="buttonName" onclientclick="window.open('[page]');return false;" />

Else you will have to set the 'target' attribute of the form to something e.g. "_blank"

Upvotes: 1

keyboardP
keyboardP

Reputation: 69372

You could try using this javascript within the Button.Attribute.Add method:

Button1.Attributes.Add("onclick", "window.open('mySite'); return false;");

You can remove the 'return false' if you want the button to continue its postback.

You can customise the javascript further. Parameter information can be found here: http://www.javascript-coder.com/window-popup/javascript-window-open.phtml

Upvotes: 1

Tomas Aschan
Tomas Aschan

Reputation: 60564

You should do that with javascript, for example using window.open().

Upvotes: 0

Related Questions