将变量添加到 ASP.NET CustomValidator

发布于 2024-07-25 12:10:43 字数 276 浏览 1 评论 0原文

我需要一个自定义验证器,它可以在调用客户端 JavaScript 验证时以某种方式合并自定义变量。 该验证器用于转发器中,转发器中的每个项目都需要使用自定义验证器,但针对其自己的变量进行验证。 这可能吗?我该怎么做?

例如,我需要它的 javascript 验证函数类似于

JavascriptValidation(sender, args, MYVARIABLE)

或者有什么方法可以将我的变量合并到“args”中? 我不确定那是什么。

I need to have a custom validator that can in some way incorporate a custom variable when calling the client-side javascript validation. 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

JavascriptValidation(sender, args, MYVARIABLE)

Or is there any way to incorporate my variable in the 'args'? I'm not sure what that is.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一影成城 2024-08-01 12:10:43

我已经发布了一篇关于转发器中的客户端自定义验证的文章。 它可能对其他人有用。

I have posted one article for Client side custom validation in repeater. It might be useful for others.

小霸王臭丫头 2024-08-01 12:10:43

您可能需要一个 expando 属性

You might want an expando attribute

皇甫轩 2024-08-01 12:10:43

变量到底从哪里来?

即它在 DOM 中可用吗?

如果是,您能否在自定义验证器中获取 DOM 节点的值?

如果没有,最好禁用客户端验证并仅在服务器上进行验证。

Where exactly does the variable come from?

i.e. is it available in the DOM?

If it is, could you get the value of the DOM node in your custom validator?

If not, it might be best to disable client-side validation and just validate on the server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文