Monday, March 26, 2012

Modal popup only if validators pass

Hi. I would like my required field validators to be enforced prior to opening the modal popup. What is the best approach?

Thanks,
Brian

In the latest release of the Toolkit the modalpopup sample page demonstrates how to show and hide the modal popup programmatically. You candownload the source code from here and check out the sample website(the Toolkit sample website is not live yet so it will not show the new page). In the click handlers of the buttons that show/hide the modal popup you can add clauses to show it in only when certain conditions are met.

// Add click handlers for buttons to show and hide modal popup on pageLoad function pageLoad() { $addHandler($get("showModalPopupClientButton"),'click', showModalPopupViaClient); $addHandler($get("hideModalPopupViaClientButton"),'click', hideModalPopupViaClient); } function showModalPopupViaClient(ev) { ev.preventDefault(); var modalPopupBehavior = $find('programmaticModalPopupBehavior'); modalPopupBehavior.show(); } function hideModalPopupViaClient(ev) { ev.preventDefault(); var modalPopupBehavior = $find('programmaticModalPopupBehavior'); modalPopupBehavior.hide(); }

No comments:

Post a Comment