Disable EventValidation for single control, is it possible?

Raúl Roa picture Raúl Roa · Jan 11, 2010 · Viewed 7.7k times · Source

I know this is a very debated topic, and usually when you are thinking about this as a solution you might want to rethink your UI logic.

I know I can pass validation using ClientScriptManager.RegisterForEventValidation. But, I'd really like to know. Is it possible to remove event validation for a single control? Is there a way work around for this?

I'm modifying a DropDownList, from the client side after it's rendered.

Answer

Dale K picture Dale K · Dec 20, 2011

The SupportsEventValidation attribute is not inherited for subclasses, so if you create a subclass of DropDownList, don't apply that attribute to the subclass, and use the subclass on your page, you will have a control that doesn't trigger event validation, even if event validation is enabled on the page.

public Class DynamicDropDownList : DropDownList
{
}

http://msdn.microsoft.com/en-us/library/system.web.ui.supportseventvalidationattribute%28v=VS.110%29.aspx