RequiredFieldValidator不工作?

时间:2018-04-19 06:14:05

标签: c# asp.net requiredfieldvalidator

当我没有在文本框中放置任何内容时,单击按钮后根本不显示该消息。这是我的代码:

    <div style="padding-top:5px">
                        <asp:Label Text="Enter Account Email Address" CssClass="required" runat="server" />
                        <asp:TextBox ID="EAdd" width="300px" runat="server" ValidationGroup="Email"/>
                        <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server"
                          ControlToValidate="EAdd"
                          ErrorMessage="This is a required field."
                          Display="Dynamic"
                          ValidationGroup="Email"
                          ForeColor="Red">
                        </asp:RequiredFieldValidator>
                        <asp:ValidationSummary id="Errors" ShowMessageBox="true" runat="server" />
                    </div>

2 个答案:

答案 0 :(得分:0)

您需要在验证摘要中添加验证组,就像

一样
<ul id="topmenu">
  <li class="langHorzMenu">
    <a href="#" id="HyperLink">French</a>
    <ul id="Submenu">
      <li>
        <a href="#">News</a>
        <ul id="Submenu">
          <li>
            <a href="#">News</a>
          </li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

答案 1 :(得分:0)

按钮是否具有相同的ValidationGroup =&#34; Email&#34;?