closing a popup form

Discussion in 'ASP .Net' started by SteveS, Apr 2, 2004.

  1. SteveS

    SteveS Guest

    Hello. This is a strange problem which does not make sense to me.

    I open a popup page with the following javascript code:

    function OpenDenyWindow(changeId) {
    retVal=window.showModalDialog('DenialEmailForm.aspx?id=1234'',
    'dialogWidth:650px; dialogHeight:700px; resizable:no;');
    //alert("Return val = " + retVal)
    }


    The screen opens fine. However, I can't get it to close after I the user
    submits the form. I run this code in my click event:

    Response.Write("<script language='javascript'>window.close();</script>")
    OR
    Page.RegisterStartupScript("AutoClose", "<script language
    =""javascript"">window.close();</script" & ">")



    Both of these statements do not work.

    The problem gets more interesting. If I don't try to close the form, then a
    duplicate popup form appears. Now, I have 2 popup forms!

    Make sense?

    This has me bewildered! Any ideas what is going on?

    Thank you for your help!!

    SteveS
     
    SteveS, Apr 2, 2004
    #1
    1. Advertisements

  2. SteveS

    Zoe Brown Guest

    where is the form submitted ? if it is submitted to itself you are probably
    seeing is close and then re-open again !
     
    Zoe Brown, Apr 2, 2004
    #2
    1. Advertisements

  3. SteveS

    SteveS Guest

    The popup form is submitted to itself through this button:

    <asp:Button ID="btnSend" Runat="server" Text="Send Denial"></asp:Button>

    Then, the click event in the code-behind sends the javascript to the page:

    Private Sub btnSend_Click(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles btnSend.Click
    ...do stuff....
    CloseWindow()
    End Sub

    Private Sub CloseWindow()
    'Response.Write("<script
    language='javascript'>window.close();</script>")
    Page.RegisterStartupScript("AutoClose", "<script language
    =""javascript"">window.parent.close();window.close();</script" & ">")
    End Sub



    So, do you think when a button is clicked on the popup form, it create
    another browser window? How can I get around this?
     
    SteveS, Apr 2, 2004
    #3
  4. Vidar Petursson, Apr 3, 2004
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.