469,927 Members | 1,910 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

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

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
Nov 18 '05 #1
2 3946
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
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
Nov 18 '05 #2
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" <Ed****@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
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

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Drew Pawlik | last post: by
1 post views Thread by CharlesA | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.