Can I call the server side CustomValidator method without assigning a ControlToValidate?

I have 3 RadioButtons from the same group, and each radioButton includes its own list. I want to check if the radio block has been checked and its elements have been selected from its list.

So, I only use CustomValidator using a server-side method that checks the conditions and runs a specific ErrorMessage.

My question is: can I name this method without assigning a customValidator to the control, since I have 3 possible radio beats?

thanks eddie

+6
source share
1 answer

It is possible to use the CustomValidator Control without setting the ControlToValidate property. This is usually done when you check multiple input controls or validate input controls that cannot be used with validation controls, such as CheckBox controls. In this case, the value of the argument parameter property is passed to the event handler for the ServerValidate event, and the client-side validation function always contains an empty string (""). However, these validation functions are still called to determine the validity of the server and client. To access the value for validation, you must programmatically refer to the input you want to validate, and then retrieve the value from the corresponding property . For example, to check the CheckBox control on a server, do not set the ControlToValidate property to validate and use the following code for the ServerValidate event handler.

http://msdn.microsoft.com/en-us/library/9eee01cx%28v=VS.100%29.aspx

+12
source

Source: https://habr.com/ru/post/891548/


All Articles