1

要显示的验证摘要:

<asp:ValidationSummary ID="ValidationSummary1" DisplayMode="BulletList"  
 EnableClientScript="true" runat="server" ValidationGroup="downloadGrp" />

必填字段验证器:

<asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode="Conditional"> 
<ContentTemplate> 

    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" 
     ControlToValidate="txtReasonForDownload" 
     ValidationExpression="^[\s\S]{0,500}$" 
     ValidationGroup="downloadGrp" 
     ErrorMessage="Max. 500 characters allowed!" runat="server">
    </asp:RegularExpressionValidator><br /> 

    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
    ControlToValidate="txtReasonForDownload" EnableClientScript="false" 
    ErrorMessage="Reason is required!" ValidationGroup="downloadGrp" 
    SetFocusOnError="true" Text="*"></asp:RequiredFieldValidator> 

    <asp:Label ID="Label2" runat="server" CssClass="error" 
    Text="Reason for Download:"></asp:Label> 
    <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"
       ValidationGroup="downloadGrp" 
       Width="200px" MaxLength="500" Enabled="False"></asp:TextBox><br /> 

</ContentTemplate> 

后面的代码:

protected void btnSubmitDownload_Click(object sender, EventArgs e) 
{ 
    string str1 = txtReasonForDownload.Text; 
    if (str1.Equals(string.Empty)) 
    { 
         reqTxtReason.IsValid = false; 
     //Response.Write("<script> alert('Reason for Download is required!'); </script>");

     } else { } 
 }

尽管启动了 requiredfieldvalidator,但验证摘要不显示验证。

4

1 回答 1

2

通过在另一个更新面板中包含验证摘要并使用与另一个更新面板相同的触发器来修复它

于 2012-09-27T18:53:55.033 回答