Jebli
Jebli

Reputation: 2825

Saving before window closes

I am saving the data when the user closes the show model window.

var btnSave = document.getElementById('<%= btnSave.ClientID %>');
btnSave.click();
window.close();

the problem is the code is working when i am debugging the code. but when it is deployed its not executing the server side code on save button click and the window is closed. Please suggest how to check if the server side save operation is completed from javascript . so that i can closed the window after that.

Upvotes: 0

Views: 419

Answers (1)

patmortech
patmortech

Reputation: 10219

You could have your btnSave handler on the server put some javascript into the page to close the window, rather than having your button click do it (remove window.close() from your client script). That way it definitely would not close until the server side operation completed.

In VB:

Page.ClientScript.RegisterStartupScript(Me.GetType, "CloseWindow", "window.close();", True)

In C#:

Page.ClientScript.RegisterStartupScript(this.GetType, "CloseWindow", "window.close();", true);

Upvotes: 2

Related Questions