-
October 6th, 2009, 10:42 PM
#1
Closing ASP.net page from server side code
I have an ASP.net application. The server side code is in C#. There is a button on the form. When that button is clicked, then a server side code should be executed and then the page should close.
When I write the code to close the page in .aspx file (by handing OnClick event) then the page closes even before the server side code can run.
I want that the server side code (for the button click handler) should first finish and then the page should close.
How to do that? Is there any way I can write code on server sid (in C#) to close the form?
-
October 7th, 2009, 05:09 AM
#2
Re: Closing ASP.net page from server side code
StringBuilder sbClientScript = new StringBuilder();
sbClientScript.Append("<script language='javascript'>");
sbClientScript.Append("window.close();");
sbClientScript.Append("</script>");
if (!Page.IsStartupScriptRegistered("winClose")) {
Page.RegisterStartupScript("winClose", sbClientScript.ToString());
}
Hope this Helps..
Aiyaz
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|