如何找到Requiredfieldvalidator

本文关键字:Requiredfieldvalidator 何找 | 更新日期: 2023-09-27 17:52:42

我有一个RequiredFieldValidator在我的页面上为我的文本框,并希望启用或禁用。因为我想检查所需的Option是否为true,那么RequiredFieldValidator将不能用于该文本框。

<asp:TextBox ID="txtReference" runat="server" ></asp:TextBox> 
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtReference"
                                                                Display="None" ErrorMessage="Reference Should Not Blank !" ValidationGroup="Ac"></asp:RequiredFieldValidator>
                                                            <ajaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtender9" runat="server"
                                                                Enabled="True" TargetControlID="RequiredFieldValidator1">
                                                            </ajaxToolkit:ValidatorCalloutExtender>
                                                             <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender7" runat="server" CompletionInterval="100"
                                                                DelimiterCharacters="" EnableCaching="False" Enabled="True" FirstRowSelected="True"
                                                                MinimumPrefixLength="1" ServiceMethod="GetReference" ServicePath="" TargetControlID="txtReference">
                                                            </ajaxToolkit:AutoCompleteExtender>

和我的代码,我试图这样做,但不工作

if (_clients.ReferenceRequired == true)
                {
                    RequiredFieldValidator1.Enabled = true;
                    AutoCompleteExtender7.Enabled = true;
                }
                else
                {
                    RequiredFieldValidator1.Enabled = false;
                    AutoCompleteExtender7.Enabled = false;
                }

但是在我的页面上找不到我的控件我该怎么做呢?

如何找到Requiredfieldvalidator

尝试将ValidationGroup设置为与页面上的正常值不同的值

   if (_clients.ReferenceRequired == true)
   {
        RequiredFieldValidator1.ValidationGroup = "Ac";
        AutoCompleteExtender7.ValidationGroup= "Ac";
    }
    else
    {
        RequiredFieldValidator1.ValidationGroup = "none";
        AutoCompleteExtender7.ValidationGroup = "none";
    }
相关文章:
  • 没有找到相关文章