<asp:UpdatePanel ID="LoginPanel" UpdateMode="Conditional" runat="server"> <ContentTemplate> <div id="login"> <div class="row"> <div class="label"> <asp:Label ID="lblUsername" Text="<%$ Resources:Login, UserNameField %>" runat="server" /> </div> <div class="field"> <asp:TextBox ID="txtUsername" MaxLength="12" runat="server" /> <asp:RequiredFieldValidator ID="rfvUsername" ControlToValidate="txtUsername" ValidationGroup="vgLogin" SetFocusOnError="true" ErrorMessage="*" ToolTip="<%$ Resources:Login, UserNameRequired %>" runat="server" /> </div> </div> <div class="row"> <div class="label"> <asp:Label ID="lblPassword" Text="<%$ Resources:Login, PasswordField %>" runat="server" /> </div> <div class="field"> <asp:TextBox ID="txtPassword" MaxLength="12" TextMode="Password" runat="server" /> <asp:RequiredFieldValidator ID="rfvPassword" ControlToValidate="txtPassword" ValidationGroup="vgLogin" SetFocusOnError="true" ErrorMessage="*" ToolTip="<%$ Resources:Login, PasswordRequired %>" runat="server" /> </div> </div> <div class="row"> <div class="label"> <asp:Label ID="lblRemember" Text="<%$ Resources:Login, RememberField %>" runat="server" /> </div> <div> <asp:CheckBox ID="chkRemember" Checked="true" ToolTip="<%$ Resources:Login, RememberToolTip %>" runat="server" /> </div> </div> <div class="buttons"> <asp:Button ID="btnLogin" Text="<%$ Resources:Login, Command %>" OnClick="btnLogin_Click" ValidationGroup="vgLogin" CausesValidation="true" runat="server" /> </div> </div> </ContentTemplate> </asp:UpdatePanel>
For the first time, validators will not check if the fields are filled or not, the form is simply submitted regardless of the fact that after this initial hiccup the form is checked correctly every time.
I know that I can just ask (and I should, independently) if Page.IsValid on the server side, but I still would like the verification to correctly warn the user input error for the first time, and not expect the server to respond first.
What am I doing wrong?
source share