zoukankan      html  css  js  c++  java
  • ValidationGroup指定后,ValidationSummary失效的解决办法。

    1.没有指定ValidationGroup,ValidationSummmary正常运行。

     <div>
            <asp:ValidationSummary ID="valsStartUp" runat="server" DisplayMode="List"   />
        </div>
        <div>
            <div>
                <asp:TextBox runat="server" ID="txtCardNumber" MaxLength="19" />
                <asp:RequiredFieldValidator runat="server" ID="valrCardNumber" ControlToValidate="txtCardNumber"
                    Display="none" ErrorMessage="* Card Number: required"   />
                <asp:RegularExpressionValidator ID="valeCardNumber" runat="server" ControlToValidate="txtCardNumber"
                    ValidationExpression="d{16,19}" ErrorMessage="* Cardnumber: Enter your full 16-19 digit card number"
                    Display="None"  />
                <ajaxToolkit:FilteredTextBoxExtender ID="ftbeCardNumber" runat="server" TargetControlID="txtCardNumber"
                    FilterType="Numbers" />
            </div> 
            <asp:Button ID="Button1" runat="server" Text="Button" />
      
           
        </div>
    

     2.指定validationGroup,ValidationSummary失效

     <div>
            <asp:ValidationSummary ID="valsStartUp" runat="server" DisplayMode="List" ValidationGroup="vagStartUp" />
        </div>
        <div>
            <div>
                <asp:TextBox runat="server" ID="txtCardNumber" MaxLength="19" />
                <asp:RequiredFieldValidator runat="server" ID="valrCardNumber" ControlToValidate="txtCardNumber"
                    Display="none" ErrorMessage="* Card Number: required" ValidationGroup="vagStartUp" />
                <asp:RegularExpressionValidator ID="valeCardNumber" runat="server" ControlToValidate="txtCardNumber"
                    ValidationExpression="d{16,19}" ErrorMessage="* Cardnumber: Enter your full 16-19 digit card number"
                    Display="None" ValidationGroup="vagStartUp" />
                <ajaxToolkit:FilteredTextBoxExtender ID="ftbeCardNumber" runat="server" TargetControlID="txtCardNumber"
                    FilterType="Numbers" />
            </div> 
            <asp:Button ID="Button1" runat="server" Text="Button"/>
      
           
        </div>
    

     解决办法:<asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="vagStartUp" />

    The default behaviour in ASP.NET is that when the user clicks a button that has no ValidationGroup specified (and has CausesValidation set to true), all validation controls that do not belong to a validation group are validated.

    Therefore, to validate a specific group, you need to set the ValidationGroup property of the button that should cause the validation (and also possibly the CausesValidation property).

    See the MSDN documentation for Button.ValidationGroup for details and an example.

  • 相关阅读:
    Python学习 —— 阶段综合练习三
    Git 学习(二)版本库创建
    Python学习(九)IO 编程 —— 文件读写
    Pydoc 本地 HTML 形式查看
    Python学习(九)IO 编程 —— 文件夹及文件操作
    在 Virtual Box 安装 Mac Os 并安装 Qt 开发应用
    滚动歌词制作 之 ncm格式转mp3
    Web —— 在自己电脑搭建网站,发布到公网,并使用域名访问
    版本控制软件的使用
    C++ —— 返回数组指针的函数 和 返回指向函数的指针的函数
  • 原文地址:https://www.cnblogs.com/kouhh/p/3635964.html
Copyright © 2011-2022 走看看