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.
A:
You should do that with javascript, for example using window.open()
.
Tomas Lycken
2009-10-11 15:17:03
+1
A:
Hi, 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
keyboardP
2009-10-11 15:22:07
+1
A:
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"
o.k.w
2009-10-11 15:22:07
how do I close the parent form on button click?
Peter
2009-10-11 17:30:20
In the page loaded at thenew window, you can add window.parent.close() and there's likely to be a browser prompt. Are you sure you want to do that?
o.k.w
2009-10-12 00:10:20