ASP.NET AJAX Postback Event Validation
In my video “How Do I Use the Cascading Drop Down Control Extender” I demonstrate setting EnableEventValidation=”false” at the page level and mention that you can leave the default (which is true) and individually authorize client event.
Since I’ve had a number of email about this, I thought I’d comment on the issue here.
It turns out that it’s actually a bit tricky in the case of using the Cascading Drop Down Control Extender when the Drop-Down values are dynamic. (Meaning they come from a data-source where items might be added after your code is written.)
The reason is that you need to SPECIFY what values are valid for the post-back.
Example, in the Render or Pre-Render methods you could:
ClientScript.RegisterForEventValidation( _MyList.SomeUniqueID, “Red”);
ClientScript.RegisterForEventValidation( _MyList.SomeUniqueID, “Green”);
ClientScript.RegisterForEventValidation( _MyList.SomeUniqueID, “Blue”);
The issue here is the “Red”, “Green” etc.
Of course, you could pull them from the database at runtime and call RegisterForEventValidation for each value.
Rather than write about all the details I’ll point you to a pair of excellent blog postings by K. Scott Allen over at OdeToCode.com
Read HERE: https://odetocode.com/Blogs/scott/archive/2006/03/20/3145.aspx
And HERE: https://odetocode.com/Blogs/scott/archive/2006/03/21/3153.aspx
Thanks Scott! Good stuff !
Comments
- Anonymous
August 14, 2007
PingBack from http://msdnrss.thecoderblogs.com/2007/08/14/aspnet-ajax-postback-event-validation/