Yesterday I saw a post on the AJAX discussion forums which stated that an extender stopped working after a partial postback. Since i”m a curious guy, i decided to take some time and investigate the code. The guy with the problem had a really simple sample that reproduced the problem (which is really cool since I really really really – i think you”ve got the picture – don”t have the time to build samples which reproduce errors 😉 ,,) . i couldn”t believe in my eyes, but he was absolutely right: after a partial postback, the extender (which was a TextBoxWaterMarkExtender) didn”t render the watermark.
Since the web app only had a page, i started by comparing the entries of the demo app with the ones of the web.config that are defined by the sample app that is available with the extenders. Besides having the registration in the web.config (instead of using the @register directive on the page), everything looked the same. After 5 minutes, i”ve spotted the difference: the demo app that had the problem disabled event validation. If you user extenders, then don”t do this…
This breaks all the extenders that need to inject script during a partial postback (and i do think that they all need to do this). And why does that happen? well, basically because the PageRequestManager class (which is used internally by the ScriptManager control) will only render the controls present on a form if event validation is active (don”t believe me? then check its RenderFormCallback with reflector – btw, this method replaces the norma rendering perform by the HtmlForm control).
Extenders will only inject their scripts (the ones you get by calling the GetDescriptor method) on a page during the Render method of the ScriptManager control. If you disable event validation, the Render method of the ScriptManager control won”t be called and that”s a really bad thing if you use extenders (which is not a problem to me since i”m a firm believer in client behaviors 😉 )
I still don”t know why it only renders the contents of its controls when even validation is active, but i can assure you that all the extenders placed inside an UpdatePanel will simply stop working after the first partial postback. now, i do really think that disabling event validation isn”t really an exotic scenario, so i”d appreciate if someone could explain why was this decision made….