Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable EventValidation for single control, is it possible?

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.

like image 663
Raúl Roa Avatar asked Jan 11 '10 13:01

Raúl Roa


People also ask

How do I turn off event validation?

To disable a validation controlSet the validation control's Enabled property to false.

How do I turn off client side validation?

To disable client-side validation, set the page's ClientTarget property to 'Downlevel' ('Uplevel' forces client-side validation). Alternatively, you can set an individual validator control's EnableClientScript property to 'false' to disable client-side validation for that specific control.

How to disable validation control in ASP net on button click?

To prevent validation from being performed, set the CausesValidation property to false . You should set the CausesValidation property to false when you are using the PostBackUrl property to post back to a different page.

What is event validation?

Event validation is pattern that developers are using, but they change the level of validation based on consumer, producer and trust between them.


1 Answers

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

like image 171
Dale K Avatar answered Oct 13 '22 23:10

Dale K