Link to home
Start Free TrialLog in
Avatar of christopher_perry
christopher_perryFlag for United States of America

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?
Avatar of christopher_perry
christopher_perry
Flag of United States of America image

ASKER

One thing to note:

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?
Here's another thing, if it helps:

The data is inserted using a WCF service.
ASKER CERTIFIED SOLUTION
Avatar of Member_2_4913559
Member_2_4913559
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ddayx10 - thanks for the feedback, it was very helpful.