加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 我可以在服务器端调用CustomValidator方法而无需分配

发布时间:2020-12-15 20:21:22 所属栏目:asp.Net 来源:网络整理
导读:我有来自同一组的3个RadioButton,每个radioButton都启用了它的列表框. 我想检查是否检查了radiobutton,以及是否从列表框中选择了项目. 所以我使用CustomValidator只使用服务器端方法来检查条件并触发特定的ErrorMessage. 我的问题是,我可以调用此方法无法将c
我有来自同一组的3个RadioButton,每个radioButton都启用了它的列表框.
我想检查是否检查了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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读