禁用RequiredFieldvalidator [英] disable RequiredFieldvalidator

查看:37
本文介绍了禁用RequiredFieldvalidator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 RequiredFieldvalidator 并且我想在某些情况下禁用它.

I have RequiredFieldvalidator and I want in certain cases to disable it.

这是RequiredFieldvalidator:

this is the RequiredFieldvalidator:

<asp:RequiredFieldValidator ID="RfvHul" runat="server" ErrorMessage="Error" ControlToValidate="txtBox" Display="None"></asp:RequiredFieldValidator>

我已经尝试过这样做,但所有这些代码行都给了我 Page_IsValid = false

and I've tried to do this but all these lines of code gave me Page_IsValid = false

 $("#RfvHul").attr("disabled", true);

 ValidatorEnable(document.getElementById("<%=RfvHul.ClientID%>"), false);

 document.getElementById("RfvHul").Enabled = false;

 $("#RfvHul").attr("Enabled", false);

感谢您的帮助!

推荐答案

您不能只是在客户端禁用它并期望服务器端代码知道它.在调用 Validate() 之前,您必须重复禁用逻辑服务器端.

You can't just disable it client side and expect the server side code to know about it. You'll have to repeat your disabling logic server side prior to calling Validate().

这篇关于禁用RequiredFieldvalidator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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