Asp .NET要求Field Validator根据条件在两个错误消息之间进行切换

时间:2017-07-05 10:46:22

标签: c# asp.net .net

带有必填输入字段的下拉列表,但我还要检查一个特定值,因此我需要有两个不同的错误消息才能切换。 到目前为止它只能显示第一个选项,而不是第二个选项(请插入)。有什么建议吗?

 <div>
     <%if (!string.IsNullOrEmpty(txtFinalized.Text))
       {%> 
         <asp:Label ID="Label23" runat="server" CssClass="stdLabel">Finalized Method<span class="mandatory"> *</span></asp:Label>
     <%}
       else
       {%> 
           <asp:Label ID="Label17" runat="server" CssClass="stdLabel">Finalized Method </asp:Label>
    <% } %>   


      <%if (userRole == ("MS_Administrator") ||
            userRole == ("MS_Expert") ||
           (userRole == ("MS_User") && (txtOwner.Text == "" || txtOwner.Text.ToUpper() == userName.ToUpper())))
         {%>

    <asp:DropDownList ID="ddlFinalizedMethod" runat="server" CssClass="stdDropdown" OnSelectedIndexChanged="ddlGxP_SelectedIndexChanged" AutoPostBack="true" onchange="myTest()" />
    <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ControlToValidate="ddlFinalizedMethod" InitialValue="0" CssClass="RequiredFieldError" ErrorMessage=" !Please select another Standard"  />    
     <%}
       else  
        {%>
        <asp:CustomValidator ID="cvFinalizedMethod" runat="server" ControlToValidate="ddlFinalizedMethod" InitialValue="0" OnServerValidate="cvFinalizedMethod_ServerValidate" CssClass="RequiredFieldError" Text="! Please insert"  />
    <asp:TextBox ID="txtFinalizedMethodDisabled" runat="server" CssClass="stdTextboxSmallDisabled" Enabled="true" />
        <% } %>    



  </div>

0 个答案:

没有答案