我有两个控件,我已经为该控件设置了必需的字段vaildators.my问题暂时我已经设置了两个控件被禁用但是这个必需的验证器正在检查两个控件是否处于禁用模式。我在点击保存按钮时检查所需的字段验证器。如何克服这个问题?
<asp:DropDownList ID="DropDownList1" Width="150" runat="server" TabIndex="17" Enabled="false"
AppendDataBoundItems="true">
<asp:ListItem Selected="True" Text="--Select Company--"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="DropDownList1"
ValidationGroup="UserDetailsGroup" InitialValue="--Select Company--" ErrorMessage="*"></asp:RequiredFieldValidator>
texboxcontrol:
<asp:TextBox ID="AcquiredDate" runat="server" Width="150" TabIndex="18" Enabled="false"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="AcquiredDate"
ValidationGroup="UserDetailsGroup" ErrorMessage="*"></asp:RequiredFieldValidator>
这里的保存按钮是图像按钮吗?
<asp:ImageButton ID="Save" runat="server" ImageUrl="~/Images/save-button.gif"
OnClick="Save_Click" TabIndex="41" ValidationGroup="UserDetailsGroup" />
如何在服务器端或客户端克服此pblm?
答案 0 :(得分:2)
禁用验证器:
RequiredFieldValidator3.Enabled = DropDownList1.Enabled
RequiredFieldValidator2.Enabled = AcquiredDate.Enabled