Reputation: 1411
I have 12 pop up pages on my site with a Save and Cancel button. My requirement is once the Save button is clicked on the pop page i want the server side code to execute and once its done I want the pop up to close.
Is that possible? If yes, kindly let me know how do I achieve that.
Upvotes: 0
Views: 973
Reputation: 1411
At the end of your code the below lines of code will help to close the window.
this.Page.Response.Clear(); this.Page.Response.Write(string.Format(CultureInfo.InvariantCulture, "window.frameElement.commonModalDialogClose(1, '{0}');", lblText.Text)); this.Page.Response.End();
Upvotes: 0
Reputation: 13756
What you can do:
Use your ScriptManager to register statrup method (JavaScript). This method will close your popup
ScriptManager.RegisterStartupScript(this,this.getType(),Guid.NewGuid().ToString(),"/your code to close popup/",true /this true will add script tags to your script so you don't have to write /);
Cheers
Sorry but this SO script wont highlight code, I don't know what is the problem.
Upvotes: 0
Reputation: 61755
You can put a small Javascript on each popup:
<script type="text/javascript">
window.close();
</script>
Once the page has loaded (and all the code is run) this Javascript should close the window. Please note, different browsers will behave differently! Some might close it, some might alert warning, others may block it completely.
As far as I know this is the only way that could close a browser window. Either way, any number of popup windows over 0 is arguably an unfriendly user design. 10+ and you should be seriously reconsidering your user friendliness!
Upvotes: 1