Closing a page from code behind

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

On my page load sub in my code behind I want to run a script and close the window. I have the script running but I can not get the window to close.

Can someone tell me how to do this. I have try calling the page unload method but I must not know how to do this.
 
is this windows forms or asp.net? I think your talking about asp.net, if
so, what I've done if it's a child page i write out javascript to close the
window using the httpcontext. You can't do this in code behind b/c it
executes on the server.

If i'm wrong and your talking about winforms just use win.close.

Hope this helps.

Nick Harris, MCSD


Lynette said:
On my page load sub in my code behind I want to run a script and close the
window. I have the script running but I can not get the window to close.
Can someone tell me how to do this. I have try calling the page unload
method but I must not know how to do this.
 
the codebehind version would stream script out to the browser
one approach is Response.Write("<script>window.close()</script>");

unless the code runs under the HSA, you will get a confirmation dialog.
 
Back
Top