The first person who can help me fix the following problem will get a free Pearson Vue MCP voucher as a little "thank you" present:
I use a RequiredFieldValidator together with a ValidatorCalloutExtender. Both are generated at run time by a custom field type (derived from BoundField) that I use inside a DetailsView. The purpose of this custom field type is to automatically generate some things that I use often in my application, so that I don't have to create template fields whenever I need such common things like validation or multiline textboxes.
This works until I put the DetailsView which uses my field type inside an UpdatePanel. When I use it in an UpdatePanel, the code for the validator generated during the postback does not set the validators attributes. This causes an error in the client side code of the ValidatorCalloutExtender, because it accesses the controltovalidate attribute of the validator, which is then undefined.
I've tried to solve this problem for several days now, but without success. So far I think the following is causing the problem: The RequiredFieldValidator calls "AddAttributesToRender" to write its attributes (like controltovalidate) to the output stream. AddAttributesToRender calls AddExpandoAttribute, and this method uses a page.ClientScript.RegisterExpandoAttribute call to generate some JavaScript code that should set the attribute on the client. However, because of some problem that I could not yet identify, this JavaScript code is either not generated, not transfered back with the PostBack, or not executed on the client. The attribute values are never set. Therefore, controltovalidate is undefined after the callback, I get a JavaScript error and my validators don't work any more.
I have created a small ASP .NET web site that reproduces the problem. You can download it from http://blog.outofcoffeeexception.de/downloads/AjaxValidatorProblem.zip.
Please help, I have no idea how I could fix this problem.
The first person who finds a clean fix for my problem (I want something I could use in production code, no dirty hacks or something like that ;) ) and posts it as reply to this forum will get a Pearson Vue MCP voucher from me. This voucher will expire on February 28th and is a "not for resale" voucher which I got for passing some beta exam. The fix must also work on my "real" project, not just on the demo I posted here.