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.

  • 相关阅读:
    通过网格拆分高德地图
    vue-router重定向 不刷新问题
    vue-scroller记录滚动位置
    鼠标滚轮更改transform的值(vue-scroller在PC端的上下滑动)
    position sticky的兼容
    js截图及绕过服务器图片保存至本地(html2canvas)
    禁止页面回退到某个页面(如避免登录成功的用户返回到登录页)
    手动创建script解决跨域问题(jsonp从入门到放弃)
    逻辑回归的常见面试点总结
    听说你不会调参?TextCNN的优化经验Tricks汇总
  • 原文地址:https://www.cnblogs.com/kouhh/p/3635964.html
Copyright © 2011-2022 走看看