简体   繁体   English

将变量添加到ASP.NET CustomValidator

[英]Adding a variable to a ASP.NET CustomValidator

I need to have a custom validator that can in some way incorporate a custom variable when calling the client-side javascript validation. 我需要有一个自定义验证器,可以在调用客户端javascript验证时以某种方式合并自定义变量。 This validator is used in a repeater, and every item in the repeater needs to use the custom validator, but validating against its own variable. 此验证器用于转发器,转发器中的每个项目都需要使用自定义验证器,但要针对其自己的变量进行验证。 Is this possible and how can I do it? 这可能吗,我该怎么办?

Example, I need its javascript validation function to be like 例如,我需要它的javascript验证功能像

JavascriptValidation(sender, args, MYVARIABLE)

Or is there any way to incorporate my variable in the 'args'? 还是有什么方法可以将我的变量合并到“ args”中? I'm not sure what that is. 我不确定那是什么。

Where exactly does the variable come from? 变量到底从哪里来?

ie is it available in the DOM? 即在DOM中可用吗?

If it is, could you get the value of the DOM node in your custom validator? 如果是这样,您能否在自定义验证器中获取DOM节点的值?

If not, it might be best to disable client-side validation and just validate on the server. 如果不是,最好禁用客户端验证,而仅在服务器上验证。

I have posted one article for Client side custom validation in repeater . 在转发器中发布了一篇有关客户端自定义验证的文章。 It might be useful for others. 对其他人可能有用。

您可能需要一个expando属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM