RequiredFieldValidator have to click twice

后端 未结 7 2046
遇见更好的自我
遇见更好的自我 2020-12-17 05:52

I have run into the same problem as described here.

Only the question is marked as answered with only an explanation as to why you may have to click twice when using

相关标签:
7条回答
  • 2020-12-17 06:29

    I have a better idea.

    Add Text="" to textbox Control.
    Add InitialValue="" to Validator Control.
    What it will do, when it will be posting, it will find the value of the text box is still the initail value and it will throw an error and the form will not be posted.

    Try this:

    <asp:RequiredFieldValidator ID="reqFieldCloseComment" ControlToValidate="tbCloseComment" ValidationGroup="ChangeStatus" ErrorMessage="Please enter a reason" Display="Dynamic" runat="server" InitialValue=""></asp:RequiredFieldValidator>
                <asp:TextBox ID="tbCloseComment" runat="server" CausesValidation="true" TextMode="MultiLine" Height="107px" Width="400px" Text=""></asp:TextBox>
    
            <asp:Button ID="btnCloseRequestFinal" Text="Finish" CssClass="CloseReqButton" runat="server" ValidationGroup="ChangeStatus" />
    
    0 讨论(0)
提交回复
热议问题