1

我的属性中有 ErrorMessage 被设置..

例如:

          <asp:TextBox ID="FullName" runat="server" ></asp:TextBox>
            <asp:TextBoxWatermarkExtender ID="Surname_TextBoxWatermarkExtender" 
                runat="server" 
                Enabled="True" 
                TargetControlID="FullName"
                WatermarkText="Full Name" 
                WatermarkCssClass="watermark"  
                ></asp:TextBoxWatermarkExtender>

              <asp:RequiredFieldValidator 
              ID="RequiredFieldValidator2"
               runat="server"
               ErrorMessage="Must insert full name"
               ControlToValidate="FullName"
               ForeColor="#FF3300"
               SetFocusOnError="True"
                ></asp:RequiredFieldValidator>

                  <asp:CustomValidator 
                ID="CustomValidator2"
                runat="server"
                ControlToValidate="FullName"
                ClientValidationFunction="EmpIDClientValidate"
                OnServerValidate="EmpIDServerValidate"
                ErrorMessage="CustomValidator"
                Display="dynamic"
                ></asp:CustomValidator>

现在我想在摘要中插入错误消息“必须插入全名”,并留下所需的控制消息只有:“*”。而摘要控件应该有完整的消息。这是我的摘要控制。

 <asp:ValidationSummary runat="server" ID="Summary"
              ShowMessageBox="true" 
              HeaderText="<b>Please review the following errors:</b>" ShowSummary="False"
            /> 

我知道它可以做到..但我不知道要添加什么属性/属性来实现这一点?

更新:

            <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
               runat="server"
               ErrorMessage="*"
               HeaderText="User name is empty"
               ControlToValidate="UserName"
               ForeColor="#FF3300" 
               Display="Dynamic"
               SetFocusOnError="True"></asp:RequiredFieldValidator>

上面的控件产生* ..这是我想要的..但​​是摘要应该采用...“用户名为空”并显示它..这里再次是摘要:

<asp:ValidationSummary runat="server" ID="Summary"
              ShowMessageBox="true" 
              HeaderText="<b>Please review the following errors:</b>" ShowSummary="False"
            /> 
4

1 回答 1

2

我发现答案应该是:

<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
               runat="server"
               Text="*"
               ErrorMessage="Field cant be empty"
               HeaderText="User name is empty"
               ControlToValidate="UserName"
               ForeColor="#FF3300" 
               Display="Dynamic"
               SetFocusOnError="True"></asp:RequiredFieldValidator>

您应该将文本..这将代表字段中的错误..并且错误消息将在验证摘要控件中表示

于 2012-04-26T15:22:39.670 回答