christopher_perry
asked on
Use JavaScript to close modal window upon button click event
I have an ASP.NET page that opens another page in a modal window. The window that is opened contains a few text boxes and a button. This window is used to add a new piece of data. When the user clicks the button, I need to validate that the text boxes contain valid data and that the data was successfully inserted into the database. If the insert was successful, the window needs to close and perform a postback on the parent page. I have very little JavaScript skills; however, I can validate the required fields, close the modal window, and perform a postback via JavaScript. However, I have no idea how to determine if the insert was successful prior to closing the window. My DB insert is currently performed as a click event of the button, but that executes after the JavaScript. How can I execute my JavaScript for closing the modal window and updating the parent page after the code for inserting into the DB executes?
ASKER
Here's another thing, if it helps:
The data is inserted using a WCF service.
The data is inserted using a WCF service.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ddayx10 - thanks for the feedback, it was very helpful.
ASKER
Currently, after the successful insertion of the record to the DB, I then call Response.Write() to execute JavaScript to close the modal window and refresh the parent page. Although this works, is there any way to do this outside of the code-behind?