Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET Form Validation Doesn't work first time
    primarykey
    data
    text
    <pre><code>&lt;asp:UpdatePanel ID="LoginPanel" UpdateMode="Conditional" runat="server"&gt; &lt;ContentTemplate&gt; &lt;div id="login"&gt; &lt;div class="row"&gt; &lt;div class="label"&gt; &lt;asp:Label ID="lblUsername" Text="&lt;%$ Resources:Login, UserNameField %&gt;" runat="server" /&gt; &lt;/div&gt; &lt;div class="field"&gt; &lt;asp:TextBox ID="txtUsername" MaxLength="12" runat="server" /&gt; &lt;asp:RequiredFieldValidator ID="rfvUsername" ControlToValidate="txtUsername" ValidationGroup="vgLogin" SetFocusOnError="true" ErrorMessage="*" ToolTip="&lt;%$ Resources:Login, UserNameRequired %&gt;" runat="server" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div class="label"&gt; &lt;asp:Label ID="lblPassword" Text="&lt;%$ Resources:Login, PasswordField %&gt;" runat="server" /&gt; &lt;/div&gt; &lt;div class="field"&gt; &lt;asp:TextBox ID="txtPassword" MaxLength="12" TextMode="Password" runat="server" /&gt; &lt;asp:RequiredFieldValidator ID="rfvPassword" ControlToValidate="txtPassword" ValidationGroup="vgLogin" SetFocusOnError="true" ErrorMessage="*" ToolTip="&lt;%$ Resources:Login, PasswordRequired %&gt;" runat="server" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div class="label"&gt; &lt;asp:Label ID="lblRemember" Text="&lt;%$ Resources:Login, RememberField %&gt;" runat="server" /&gt; &lt;/div&gt; &lt;div&gt; &lt;asp:CheckBox ID="chkRemember" Checked="true" ToolTip="&lt;%$ Resources:Login, RememberToolTip %&gt;" runat="server" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="buttons"&gt; &lt;asp:Button ID="btnLogin" Text="&lt;%$ Resources:Login, Command %&gt;" OnClick="btnLogin_Click" ValidationGroup="vgLogin" CausesValidation="true" runat="server" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p>The first time around, validators won't check whether the fields are completed or not, the form just gets submitted no matter what, after that initial hiccup, the form validates correctly each time.</p> <p>I know I can just ask (and should, regardless) if <code>Page.IsValid</code> at server-side, but I still would like the validation to correctly alert the user input mistake the first time around instead of waiting for the server response first.</p> <p>What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload