如何隐藏/显示 CustomValidation 验证消息而不回发
更新:弄清楚了.. 我传递给 ValidatorHookupControl 的对象未正确设置(为空)。现在,当连接的控件失去焦点时,消息会立即消失。
原始帖子..
嗨,
我有一些 ClientValidation 控件,它们具有ClientSideValidation 方法在验证页面时工作正常。
但是,我怎样才能做到这一点,以便当 CustomValidators 客户端方法的某个控件启动时,并根据验证是否通过来更新验证消息或不。 (例如 RequiredFieldValidator 或 RegExValidator)。
我的 Customvalidators 没有设置 ControltoValidate 属性,因为其中一些依赖于多个控件。
我不需要任何回发(全部或部分)。
我尝试过..
- 在下拉菜单、单选框和复选框上添加一个 onchange 属性,这些属性调用一个帮助程序客户端方法,该方法调用
Page_ClientValidate('GroupName')
,然后将 window.location 设置回有问题的控件(如它返回到屏幕顶部)。
使用此方法,args.IsValid 仍由 ClientSideValidation 方法设置。
- 我尝试过 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..
- 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.
- And I have tried ValidatorHookupControl (control, validator) but that doesn't seem to work either.
Any thoughts..?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的缺点是将 null 对象传递到 ValidatorHookupControl 方法中。
现在可以工作了。哎哟!
My bad, was passing null objects into the ValidatorHookupControl method.
Works now. Doh!