我想检查是否检查了radiobutton,以及是否从列表框中选择了项目.
所以我使用CustomValidator只使用服务器端方法来检查条件并触发特定的ErrorMessage.
我的问题是,我可以调用此方法无法将customValidator分配给控件,因为我有3个可能的radioButtons?
谢谢,
埃迪
解决方法
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