Page.Isvalid正在考虑禁用验证控件! [英] Page.Isvalid is considering disabled Validation control also !

查看:75
本文介绍了Page.Isvalid正在考虑禁用验证控件!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的情况,我需要在选择一个单选按钮对一个文本框来禁用验证控件.我已使用以下代码段通过Javascript实现了此目的:

Hi all,

I have situation where I need to disable a validation control against a text box when a radio button is selected. I have achieved this using Javascript using following code snippet:

document.getElementById(''<%= textTest.ClientID %>'').disabled = true;
ValidatorEnable(document.getElementById(''<%=RequiredTest.ClientID%>''),false);



它工作正常..但是在页面加载时,当控件执行Page.Validate()时,由于Java脚本中的已禁用控件,因此Page.Isvalid 给我提供了错误.

请帮助我解决问题,如何使它在页面加载时通过?

提前谢谢!

问候,
Divya



It is working fine .. but at page load when control executes Page.Validate() then Page.Isvalid is giving me false because of the disabled controlled in Java Script.

Please help me in solving the issue, How can i make it to pass through at page load ?

Thanks in advance!

Regards,
Divya

推荐答案

如果您从客户端禁用验证器,则在服务器端调用Page.Validate,那么禁用的验证器也会触发.

这里有两个选择.一个可以从服务器端本身禁用验证器,然后它将正常工作.

或根据需要使用一些验证组,如果您想触发验证调用Page.请使用此组名进行验证,否则不要使用此组名进行调用.

一个建议,如果您在客户端的控件上进行验证,那么根据您的安全考虑,您可以避免服务器端验证,这也将提高性能.

希望对您有所帮助.

也可以仔细阅读以下文章.
探索ASP.NET验证程序
If you disable the validator from Clientside then at serverside if you''ll call Page.Validate then you disabled validator will also fire.

Here you have two option.One you can disable the validator from server side itself then it''ll work fine.

or use some validationgroup and according to your requirement if you want to fire the validation call Page.Validate with this group name else dont call with this group name.

One suggestion, if your validating at control at clientside, then according to your security concern, you can avoid server side validation, it''ll also better for performance.

Hope it helps.

Also can go through the following article for detail.
Exploring ASP.NET Validators


这篇关于Page.Isvalid正在考虑禁用验证控件!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆