Blog Post RSS ?

Blogs » .NET » I [heart] the ModalPopup
 

I [heart] the ModalPopup

by Wyatt Barnett

In case you missed it, there was a September release of the Atlas Control Toolkit. Now, the big new feature is animation support. Which I must say is cool. But then again, if I wanted animation I would use flash. But there is another control in the toolkit which I have fallen in love with for a number of reasons: the ModalPopup.

Why do I like it so much, you ask? Mainly because it allows a developer to do things like create a complex confirmation dialog. Or make a pop-up add item form without an actual pop-up. All without writing a lick of JavaScript. And I suck at javascript.

There is, however, one big trick to making the ModalPopup post back to the server-side that the published examples do not make clear—how to allow the popup panel to fire a post-back. And, after half a day of struggling, I found the answer was actually disturbingly simple: just make sure any button you wish to post back is not handled by the ModalPopupExtender by simply ignoring the OnOkScript property.

The other issue a developer need be aware of is how validation controls behave when a ModalPopup comes into the picture:

  • If the validator is on the underlying form, the client-side validators are ignored. The Page’s IsValid property is properly set. Which means, you, as the developer, must gracefully handle the potential invalidity of the submission coming out of the ModalPopup. I suspect someone a bit craftier than I with client-side script could find a way to prevent the popup from firing if the form was invalid.
  • If the validators are on the control which is popped up, the client-side validation works nicely. However, CustomValidators without requisite client-side script will allow the form to be posted back, and the ModalPopup is not visible after postback.

Enjoy and keep it poppin’.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Ping.fm
  • Twitthis

Related posts:

  1. Cookie-less Session Variables in JavaScript Cookies may be delicious, but they can be clumsy if...
  2. Server-side JavaScript Will Be as Common as PHP Despite the fact that JavaScript has been typecast as the...
  3. Will Server-Side JavaScript ever catch on? Server-side JavaScript appears to be a logical choice for web...
  4. Google Releases its JavaScript Closure Tools Do we need more JavaScript libraries and tools? Perhaps not,...
  5. 10 Things to Check Before Using a CAPTCHA Hacking attempts and spam bots are your problem - not...

This post has 12 responses so far

Sponsored Links

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.

Follow SitePoint on...