How to open a new browser window in ASP.net?

  • Thread starter Miguel Dias Moura
  • Start date
M

Miguel Dias Moura

Hello,

i have an ASP.net page with a button. When the button is clicked i want to
open a new Browser window (400x200px) having only the title bar and nothing
else.This browser window would load newpage.aspx in it.

I would also like to know how to create a button to insert in newpage.aspx
and that would close that same window.

I have no idea of how to do this and until now i didn't find some
information that might help me out.

I am working in ASP.net / VB

Thank You,
Miguel
 
N

Nicola Garone

To open a new window as you want try this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Response.Write("<script>window.open('prova.asp','_new',
'width=400,height=200');</script>")
End Sub
Refer to javascript function window.open to change what's displayed or not
(the 3rd parameter is window opstion)

To close the window add the button (I used ImageButton) and on page load add
imgbtClose.Attributes("onclick") = "Javascript:window.close();"
or
imgbtClose.Attributes.Add("onclick", "Javascript:window.close();")


Hope this help
Nicola Garone
 
S

steven chong

you can do this in javascript

function fnLoadNewWindow(strUrl)
{
window.open(strUrl,null,"height=200,width=400,status=no,toolbar=no,menubar=no,location=no");
}

<input type="button" onclick="fnLoadNewWindow('newpage.aspx');" />

you can also use onclick="window.close();" to close the popup later.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top