Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. problem in closing the window

problem in closing the window

Scheduled Pinned Locked Moved ASP.NET
help
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pankaj Garg
    wrote on last edited by
    #1

    following is the code i am writing to open a dialog box string str1 = "window.showModalDialog('child.aspx',null,'status:no;dialogWidth:300px;dialogHeight:150px;dialogHide:true;help:no;scroll:no');"; ScriptManager.RegisterStartupScript(Page, typeof(Page), "", str1, true); there is a button called close in the child.aspx page. in clicking the button , i want to close the window. if (!Page.IsPostBack) { // this.Title = "hnihui"; //"window.opener.location=window.opener.location; string str = "window.close();"; Button1.Attributes.Add("onclick", str); } but the code does not close the window. Please help.

    If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

    B E V L 4 Replies Last reply
    0
    • P Pankaj Garg

      following is the code i am writing to open a dialog box string str1 = "window.showModalDialog('child.aspx',null,'status:no;dialogWidth:300px;dialogHeight:150px;dialogHide:true;help:no;scroll:no');"; ScriptManager.RegisterStartupScript(Page, typeof(Page), "", str1, true); there is a button called close in the child.aspx page. in clicking the button , i want to close the window. if (!Page.IsPostBack) { // this.Title = "hnihui"; //"window.opener.location=window.opener.location; string str = "window.close();"; Button1.Attributes.Add("onclick", str); } but the code does not close the window. Please help.

      If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      if (!Page.IsPostBack) { // this.Title = "hnihui"; //"window.opener.location=window.opener.location; string str = "window.close();"; Page.RegisterClientScriptBlock("CloseWindow",str); Button1.Attributes.Add("onclick", str); }


      I Love T-SQL "Don't torture yourself,let the life to do it for you."

      1 Reply Last reply
      0
      • P Pankaj Garg

        following is the code i am writing to open a dialog box string str1 = "window.showModalDialog('child.aspx',null,'status:no;dialogWidth:300px;dialogHeight:150px;dialogHide:true;help:no;scroll:no');"; ScriptManager.RegisterStartupScript(Page, typeof(Page), "", str1, true); there is a button called close in the child.aspx page. in clicking the button , i want to close the window. if (!Page.IsPostBack) { // this.Title = "hnihui"; //"window.opener.location=window.opener.location; string str = "window.close();"; Button1.Attributes.Add("onclick", str); } but the code does not close the window. Please help.

        If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

        E Offline
        E Offline
        eyeseetee
        wrote on last edited by
        #3

        btn_close.Attributes.Add("onclick", "window.close(); return false;"); try that

        P 1 Reply Last reply
        0
        • E eyeseetee

          btn_close.Attributes.Add("onclick", "window.close(); return false;"); try that

          P Offline
          P Offline
          Pankaj Garg
          wrote on last edited by
          #4

          i am opening an aspx page in the form of dialog box . While i am using ur code , it is not even closing the window , but also opening the same page i pop up window

          If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

          E 1 Reply Last reply
          0
          • P Pankaj Garg

            i am opening an aspx page in the form of dialog box . While i am using ur code , it is not even closing the window , but also opening the same page i pop up window

            If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

            E Offline
            E Offline
            eyeseetee
            wrote on last edited by
            #5

            What do you mean by

            Pankaj Garg wrote:

            but also opening the same page i pop up window

            1 Reply Last reply
            0
            • P Pankaj Garg

              following is the code i am writing to open a dialog box string str1 = "window.showModalDialog('child.aspx',null,'status:no;dialogWidth:300px;dialogHeight:150px;dialogHide:true;help:no;scroll:no');"; ScriptManager.RegisterStartupScript(Page, typeof(Page), "", str1, true); there is a button called close in the child.aspx page. in clicking the button , i want to close the window. if (!Page.IsPostBack) { // this.Title = "hnihui"; //"window.opener.location=window.opener.location; string str = "window.close();"; Button1.Attributes.Add("onclick", str); } but the code does not close the window. Please help.

              If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

              V Offline
              V Offline
              Vinay Dornala
              wrote on last edited by
              #6

              Hi, You can call Window.Close() in OnClientClick , This will close current window.( If it is popup this will close popup window)

              1 Reply Last reply
              0
              • P Pankaj Garg

                following is the code i am writing to open a dialog box string str1 = "window.showModalDialog('child.aspx',null,'status:no;dialogWidth:300px;dialogHeight:150px;dialogHide:true;help:no;scroll:no');"; ScriptManager.RegisterStartupScript(Page, typeof(Page), "", str1, true); there is a button called close in the child.aspx page. in clicking the button , i want to close the window. if (!Page.IsPostBack) { // this.Title = "hnihui"; //"window.opener.location=window.opener.location; string str = "window.close();"; Button1.Attributes.Add("onclick", str); } but the code does not close the window. Please help.

                If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!

                L Offline
                L Offline
                l0kke
                wrote on last edited by
                #7

                I don't know if that's your problem, but I remember that I was struggling few years ago with something similar. The headache was caused by the fact that postback in modal window doesn't really work as expected. The workaround was to do all the popup window eventhandling on clientside with javascript, or, better solution, have a iframe in your popup window and load your aspx page into that iframe. It is possible that your problem is something different, I just wanted to mention that this can be the case :)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups