Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i call CustomValidator method on server side without assigning ControlToValidate?

I have 3 RadioButtons from same group, and every radioButton enables its listbox. I want to check if radiobutton was checked and its if items were selected from its listbox.

So I"m using CustomValidator with only server side method which checks the conditions and fires the specific ErrorMessage.

My question is, can i call this method witout assigning the customValidator to a control, since i have 3 possible radioButtons?

thanks, Eddie

like image 500
Eddie Rozenblat Avatar asked Jun 28 '11 11:06

Eddie Rozenblat


1 Answers

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

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

like image 57
Tim Schmelter Avatar answered Sep 22 '22 15:09

Tim Schmelter