Hi Kevin
I have a server side button which needs to execute some code on the server,
then close the browser. Are you suggesting in the Page_Load, or prehaps the
button event (button_OnClick) I incorporate something like:
private void Page_Load(object sender, EventHandler e) {
if(IsPostback) {
// do server stuff, like clean out the session
// Session["var']=null;
Page.RegisterStartupScriptBlock("startup", "<script> window.close();
</script>");
}
}
I was attempting to do some sort of client script callback, whereby the
server script could call some client script, that way I could keep the
window.close() script 'pre-rendered' on the client. If you have a sample, I
would greatly appreciate it.
Craig
"Kevin Spencer" <ke***@takempis.com> wrote in message
news:up**************@tk2msftngp13.phx.gbl...
You can't. You're not trying to close a WebForm; you're trying to close
the browser. The browser is on the client. All ASP.Net sends to the browser is
an HTTP response with HTML in it. You need to add a Startup JavaScript to
the page during PostBack that closes the browser window on the client
side.
--
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big things are made up of
lots of little things.
"Craig Pearson" <pe******@un.org> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... How can I close a web form from code-behind code, insteal of client
script i.e javascript:window.close();
craig