How do I use a <asp:button> to close a window

Discussion in 'ASP .Net' started by =?Utf-8?B?RWQgQ2hpdQ==?=, Oct 28, 2004.

  1. Hi,

    I would like to add a <asp:button> to a webform. When user click on this
    button, the page will connect to SQL server and update tables, then the
    browser window will be closed.

    I know how to connect to SQL server and update tables but I don't know how
    to close browser window after that. The SQL server part is on the server
    side, closing window is on client side.

    TIA
     
    =?Utf-8?B?RWQgQ2hpdQ==?=, Oct 28, 2004
    #1
    1. Advertising

  2. Ed Chiu wrote:
    > I would like to add a <asp:button> to a webform. When user click on this
    > button, the page will connect to SQL server and update tables, then the
    > browser window will be closed.
    >
    > I know how to connect to SQL server and update tables but I don't know how
    > to close browser window after that. The SQL server part is on the server
    > side, closing window is on client side.


    Ed, in your Button's Click event handler, you'll have to inject some
    client-side JavaScript (namely, self.close();). You can accomplish this
    using the Page.RegisterClientScriptBlock() method. I discuss this
    method, closing windows, and how to achieve other common client-side
    techniques in ASP.NET, in this article of mine:

    Working with Client-Side Script
    http://tinyurl.com/3w474

    Happy Programming!

    --

    Scott Mitchell

    http://www.4GuysFromRolla.com

    * When you think ASP.NET, think 4GuysFromRolla.com!
     
    Scott Mitchell [MVP], Oct 28, 2004
    #2
    1. Advertising

  3. =?Utf-8?B?RWQgQ2hpdQ==?=

    Saravana Guest

    after you fetch the details from sql server. Write the following line

    Page.RegisterStartupscript("name","<script language="javascript">
    window.close() </script>")



    --
    Saravana
    http://dotnetjunkies.com/WebLog/saravana/
    www.ExtremeExperts.com


    "Ed Chiu" <> wrote in message
    news:D...
    > Hi,
    >
    > I would like to add a <asp:button> to a webform. When user click on this
    > button, the page will connect to SQL server and update tables, then the
    > browser window will be closed.
    >
    > I know how to connect to SQL server and update tables but I don't know how
    > to close browser window after that. The SQL server part is on the server
    > side, closing window is on client side.
    >
    > TIA
     
    Saravana, Oct 29, 2004
    #3
    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. Replies:
    6
    Views:
    8,876
    sateeshranga
    Aug 7, 2008
  2. Jeremy Bowers
    Replies:
    3
    Views:
    433
    jrlen balane
    Mar 14, 2005
  3. Iñaki Baz Castillo
    Replies:
    7
    Views:
    896
    Iñaki Baz Castillo
    Jan 12, 2010
  4. Walter Beierdonck

    Self.close() window without the dialog close?Yes/NO

    Walter Beierdonck, Apr 29, 2004, in forum: Javascript
    Replies:
    1
    Views:
    357
    Grant Wagner
    Apr 30, 2004
  5. Shang Wenbin

    close current window using window.close()

    Shang Wenbin, Sep 1, 2005, in forum: Javascript
    Replies:
    10
    Views:
    395
    Gérard Talbot
    Sep 2, 2005
Loading...

Share This Page