Results 1 to 5 of 5

Thread: How to open a new browser window from ASPX page *RESOLVED*

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982

    How to open a new browser window from ASPX page *RESOLVED*

    I really could do with knowing how to open a new browser window with an aspx page from an aspx page.

    I currently have a response.redirect call in the click event of a button. When the button is clicked i need to display an aspx page in a new window.

    Last edited by davidrobin; Sep 28th, 2004 at 10:34 AM.


    Things I do when I am bored: DotNetable

  2. #2
    Lively Member
    Join Date
    Nov 2002
    Location
    Cranston, RI
    Posts
    110
    Sorry, did this in C# so just make the changes to your vb.net...

    Instead of using Response.Redirect() declare a string with the following jscript code:

    string scriptString = "<script language=JScript >";
    scriptString += "window.open('[name of .aspx page]','_blank','menubar=no,resizable=no,scrollbars=yes,toolbar=no,height=400,width=650');";
    scriptString += "</script>";

    Then once you have this declared, use RegisterStartupScript()

    if(!Page.IsStartupScriptRegistered("Startup"))
    Page.RegisterStartupScript("Startup", scriptString);

    You can look up the Window.Open() command on the MSDN at
    http://msdn.microsoft.com/library/de...ods/open_0.asp

    Don't know if this works for Netscape. Worth a try though and hope this helps you.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    That works an absolute treat.
    I only had to make minimal changes and put all the code in the button click event.
    I was wondering if some should go in form load and some in the button click but it works.

    As for netscape, it is policy for all machines have IE so no problems there.


    Things I do when I am bored: DotNetable

  4. #4
    Lively Member
    Join Date
    Nov 2002
    Location
    Cranston, RI
    Posts
    110
    I keep it all in the click event. No need to have code all over the place when keeping it all local does the trick.

    Glad to have helped.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    Good to know I did it right then.

    It worked so all is well.


    Things I do when I am bored: DotNetable

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width