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

G

Guest

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
 
S

Scott Mitchell [MVP]

Ed said:
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
(e-mail address removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
S

Saravana

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

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

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

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top