开发者

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

开发者 https://www.devze.com 2022-12-08 09:59 出处:网络
I am working on ASP.net using VB.net. I need to load a page in a new windo开发者_JAVA百科w on button click.

I am working on ASP.net using VB.net. I need to load a page in a new windo开发者_JAVA百科w on button click. Can someone suggest the code for the same.


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"


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号