Closing window/page

Discussion in 'ASP .Net Web Controls' started by Zamdrist, Dec 29, 2005.

  1. Zamdrist

    Zamdrist Guest

    Use code-behind form, visual basic, running some code behind a command
    button, all good...the last step though should be that the use is
    prompted with a message, and then the window or page should
    close...can't figure out how to do this otherwise simple task.

    I imagine DHTML could do it, but I should be able to access the browser
    window's methods from VB.Net also, right?

    I tried the obvious...Page.Close...well there is no Close method, and
    Dispose isn't right...

    Could someone point me in the right drection? Thanks!

    Steve
     
    Zamdrist, Dec 29, 2005
    #1
    1. Advertising

  2. Zamdrist

    Zamdrist Guest

    Ok...figured that part out...must you client side code in order to use
    the Close method of the Window object.

    Well, that leaves me in a bind...the button still first needs to run
    code, VB.Net code...and close the window...can I do both?
     
    Zamdrist, Dec 29, 2005
    #2
    1. Advertising

  3. Zamdrist

    addup Guest

    use page.registerstartupscript
    and run window.close from there

    note that many browsers will show an alert if you use this to close a
    window that has been explicitly opened by the user
     
    addup, Dec 29, 2005
    #3
  4. Zamdrist

    Zamdrist Guest

    Most excellent...now if I could just figure out what the 'key' value
    really represents so that it actually runs it...

    addup wrote:
    > use page.registerstartupscript
    > and run window.close from there
    >
    > note that many browsers will show an alert if you use this to close a
    > window that has been explicitly opened by the user
     
    Zamdrist, Dec 29, 2005
    #4
  5. Zamdrist

    Zamdrist Guest

    Unfortuantely the example provided my MS here:

    ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemWebUIPageClassRegisterStartupScriptTopic.htm

    1. Shows the example not using code-behind VB, but client side only
    2. The Key value appears by thier example so arbitrary value assiged by
    the coder by random. Would make sense if the id value of the script
    block matched the key value argument of RegisterStartupScript but that
    doesn't appear to be the case (I tried).

    <sigh>
     
    Zamdrist, Dec 29, 2005
    #5
  6. Zamdrist

    addup Guest

    LOL

    I just use a generic function in my (common) base class

    Public Sub RunScript(ByVal Page As System.Web.UI.Page, ByVal Script As
    String)
    Static iSeq As Integer = 0
    Page.RegisterStartupScript("Script" & iSeq, "<SCRIPT
    language='javascript'>" & Script & "</SCRIPT>")
    iSeq += 1
    End Sub


    that I can invoke simply by

    RunScript("window.close();")
     
    addup, Dec 29, 2005
    #6
  7. Zamdrist

    Zamdrist Guest

    That works perfect!

    Well after I added the Page argument to RunScript...call :)

    Thank you very much addup!
     
    Zamdrist, Dec 29, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2lsZWVzaA==?=
    Replies:
    4
    Views:
    33,926
    =?Utf-8?B?U29sZWwgU29mdHdhcmU=?=
    Oct 14, 2004
  2. Patrick Olurotimi Ige

    Closing child window when opening a new Window

    Patrick Olurotimi Ige, Dec 14, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    448
    Patrick Olurotimi Ige
    Dec 14, 2004
  3. Satya
    Replies:
    0
    Views:
    437
    Satya
    Dec 15, 2005
  4. =?Utf-8?B?Vk1J?=

    Closing popup window when closing parent window?

    =?Utf-8?B?Vk1J?=, Feb 14, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    657
    Thomas Hansen
    Feb 15, 2007
  5. thomas
    Replies:
    0
    Views:
    230
    thomas
    Oct 23, 2003
Loading...

Share This Page