如何隐藏/显示 CustomValidation 验证消息而不回发

发布于 2024-08-19 12:04:12 字数 907 浏览 2 评论 0原文

更新:弄清楚了.. 我传递给 ValidatorHookupControl 的对象未正确设置(为空)。现在,当连接的控件失去焦点时,消息会立即消失。


原始帖子..

嗨,

我有一些 ClientValidation 控件,它们具有ClientSideValidation 方法在验证页面时工作正常。

但是,我怎样才能做到这一点,以便当 CustomValidators 客户端方法的某个控件启动时,并根据验证是否通过来更新验证消息或不。 (例如 RequiredFieldValidator 或 RegExValidator)。

我的 Customvalidators 没有设置 ControltoValidate 属性,因为其中一些依赖于多个控件。

我不需要任何回发(全部或部分)。

我尝试过..

  1. 在下拉菜单、单选框和复选框上添加一个 onchange 属性,这些属性调用一个帮助程序客户端方法,该方法调用 Page_ClientValidate('GroupName'),然后将 window.location 设置回有问题的控件(如它返回到屏幕顶部)。

使用此方法,args.IsValid 仍由 ClientSideValidation 方法设置。

  1. 我尝试过 ValidatorHookupControl (控制,验证器)但这似乎也不起作用。

有什么想法吗..?

UPDATE : Figured it out..
The objects I was passing to the ValidatorHookupControl were'nt being set properly (were null). Now that they are, the messages are currectly dissapearing when the hooked up control looses it's focus.


ORIGINAL POST ..

Hi,

I have some ClientValidation controls that have ClientSideValidation methods which work fine when validating the page..

However, how can I make it so that when a certain control that a CustomValidators clientside method kicks in and udates the validation message depending on whether the validation has passed or not. (Like the RequiredFieldValidator or RegExValidator).

My Customvalidators do not have their ControltoValidate properties set as some of them depend on multiple controls.

I don't want any postbacks (full or partial).

I have tried..

  1. Adding an onchange attribute on dropdowns, radioboxes and checkboxes that call a helper clientside method which calls Page_ClientValidate('GroupName'), then setting window.location back to the control in question (as it went back to top of screen).

Using this method the args.IsValid is still being set by the ClientSideValidation method.

  1. And I have tried ValidatorHookupControl (control, validator) but that doesn't seem to work either.

Any thoughts..?

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

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

发布评论

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

评论(1

最美的太阳 2024-08-26 12:04:12

我的缺点是将 null 对象传递到 ValidatorHookupControl 方法中。
现在可以工作了。哎哟!

My bad, was passing null objects into the ValidatorHookupControl method.
Works now. Doh!

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