Closing a window using a ASP:ImageButton

Discussion in 'ASP .Net Building Controls' started by thechaosengine, Apr 28, 2005.

  1. Hi all,

    I need to be able to cause the following chain of events after clicking an
    asp:button but I don't know how to do it. I'd really appreciate any advice
    on this or alternative approaches:

    The window in question is a popup asking the user to provide some details.
    The primary window is still open in the background

    1. Button on popup clicked
    2. Information on form saved to database
    3. Popup closes
    4. Primary window refreshes or is redirected

    I really hope someone can advise on how to achieve this

    Thanks all

    tce
     
    thechaosengine, Apr 28, 2005
    #1
    1. Advertising

  2. thechaosengine

    mortb Guest

    You'd have to out put some javascript to your page after its postback.
    Use the Page.RegisterStartupScript method.

    popup codebehind:

    void button_onclick(...)
    {
    // add code to save data to DB

    yourjavascript = "<script language='javascript'>";
    yourjavascript += "self.parent.location = self.parent.location.href;
    // this will refresh your parent window.";
    yourjavascript += "self.close(); // close popup";
    yourjavascript += "</script>"
    Page.RegisterStartupScript( yourJavascript):
    }


    "thechaosengine" <none> wrote in message
    news:...
    > Hi all,
    >
    > I need to be able to cause the following chain of events after clicking an
    > asp:button but I don't know how to do it. I'd really appreciate any advice
    > on this or alternative approaches:
    >
    > The window in question is a popup asking the user to provide some details.
    > The primary window is still open in the background
    >
    > 1. Button on popup clicked
    > 2. Information on form saved to database
    > 3. Popup closes
    > 4. Primary window refreshes or is redirected
    >
    > I really hope someone can advise on how to achieve this
    >
    > Thanks all
    >
    > tce
    >
    >
     
    mortb, Apr 28, 2005
    #2
    1. Advertising

  3. thechaosengine

    Karl Seguin Guest

    In the image click event, after saving the information, do something like:

    dim script as string = "<script language=""javascript"">" &
    System.Environment.NewLine & "self.close();" & System.Environment.NewLine &
    "</script>"
    Page.RegisterStartupScript("PopupClose", script)


    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
    http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    come!)


    "thechaosengine" <none> wrote in message
    news:...
    > Hi all,
    >
    > I need to be able to cause the following chain of events after clicking an
    > asp:button but I don't know how to do it. I'd really appreciate any advice
    > on this or alternative approaches:
    >
    > The window in question is a popup asking the user to provide some details.
    > The primary window is still open in the background
    >
    > 1. Button on popup clicked
    > 2. Information on form saved to database
    > 3. Popup closes
    > 4. Primary window refreshes or is redirected
    >
    > I really hope someone can advise on how to achieve this
    >
    > Thanks all
    >
    > tce
    >
    >
     
    Karl Seguin, Apr 28, 2005
    #3
  4. thechaosengine

    Karl Seguin Guest

    oppss..I forgot the parent refresh in mind :) well, now you have the c# and
    vb.net version...just add mort's self.parent.location... to my script
    variable if you need it in vb.net

    On the flip side, RegisterStartupScript always takes 2 parameters...the
    first being the key...

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
    http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    come!)


    "mortb" <mortb1<noospam<@hotmail.com> wrote in message
    news:uS4gGL%...
    > You'd have to out put some javascript to your page after its postback.
    > Use the Page.RegisterStartupScript method.
    >
    > popup codebehind:
    >
    > void button_onclick(...)
    > {
    > // add code to save data to DB
    >
    > yourjavascript = "<script language='javascript'>";
    > yourjavascript += "self.parent.location =
    > self.parent.location.href; // this will refresh your parent window.";
    > yourjavascript += "self.close(); // close popup";
    > yourjavascript += "</script>"
    > Page.RegisterStartupScript( yourJavascript):
    > }
    >
    >
    > "thechaosengine" <none> wrote in message
    > news:...
    >> Hi all,
    >>
    >> I need to be able to cause the following chain of events after clicking
    >> an asp:button but I don't know how to do it. I'd really appreciate any
    >> advice on this or alternative approaches:
    >>
    >> The window in question is a popup asking the user to provide some
    >> details. The primary window is still open in the background
    >>
    >> 1. Button on popup clicked
    >> 2. Information on form saved to database
    >> 3. Popup closes
    >> 4. Primary window refreshes or is redirected
    >>
    >> I really hope someone can advise on how to achieve this
    >>
    >> Thanks all
    >>
    >> tce
    >>
    >>

    >
    >
     
    Karl Seguin, Apr 28, 2005
    #4
    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:
    34,004
    =?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:
    453
    Patrick Olurotimi Ige
    Dec 14, 2004
  3. thechaosengine

    Closing a window using a ASP:ImageButton

    thechaosengine, Apr 28, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,553
    Karl Seguin
    Apr 28, 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:
    666
    Thomas Hansen
    Feb 15, 2007
  5. thomas
    Replies:
    0
    Views:
    241
    thomas
    Oct 23, 2003
Loading...

Share This Page