Stop Form from disappearing
<p>I have the following html Login form and code behind which almost works as expected. If a user provides invalid credentials, I want the form to remain and display the label <code>InvalidCredentialsMessage</code>. However, the form closes after the <code>LoginButton_Click</code> event.</p>

<p>What is causing the form to close? How do I stop it closing only when wrong credentials are provided?</p>

<p>TestPage.aspx:</p>

<pre><code>&lt;div id="login"&gt;
&lt;a href="#" id="lclose"&gt;&lt;/a&gt;

        &lt;form action="#" runat="server"&gt;
            &lt;fieldset&gt;
                &lt;div class="frame"&gt;
                    &lt;h4&gt;Login&lt;/h4&gt;
                    &lt;small&gt;Sign in to your account.&lt;/small&gt;
                    &lt;div class="clear"&gt;&lt;/div&gt;
                    &lt;input type="text" value="Username" class="input-text autoclear" /&gt;
                    &lt;input type="password" value="Password" class="input-text autoclear"/&gt;
                &lt;/div&gt;

                &lt;div class="separator"&gt;&lt;/div&gt;
                &lt;Label id="InvalidCredentialsMessage" runat="server" ForeColor="Red" 
        Text="Your username or password is invalid. Please try again."      
        Visible="False"&gt;&lt;/Label&gt; &lt;/p&gt;
                &lt;div class="separator"&gt;&lt;/div&gt;

                &lt;div&gt;
                &lt;input type="submit" value="Sign in" class="input-submit float-right" runat="server" onserverclick="LoginButton_Click"/&gt;
                &lt;a href="#" class="float-left"&gt;Forgot your password?&lt;/a&gt;
                &lt;/div&gt;

            &lt;/fieldset&gt;
        &lt;/form&gt;

&lt;/div&gt;
</code></pre>

<p>TestPage.aspx.cs:</p>

<pre><code>protected void LoginButton_Click(object sender, EventArgs e)
{
    // Validate the user against the Membership framework user store
    if (Membership.ValidateUser(Un.Value, Pw.Value))
    {
        // Log the user into the site
        FormsAuthentication.RedirectFromLoginPage(Un.Value,true);
    }
    // If we reach here, the user's credentials were invalid
    InvalidCredentialsMessage.Visible = true;
}
</code></pre>

<p>EDIT:</p>

<p>I'm trying to learn asp.net from a work colleague's template. Since posting the question, I I've been examining things in more detail and have found the following.  The form appears full screen when opening and disappears when submiting/closing. I assume this is using jQuery/AJAX to control the form as there is a jquery.form.js file?</p>

<p>The CSS contains</p>

<pre><code>.lclose {position:absolute;top:15px;right:15px;font-size:11px;background:url(../img/lclose.jpg) no-repeat top left;width:11px;height:12px;display:block;}

#login .input-submit {background:url(../img/login-input-submit.jpg) no-repeat top left;width:75px;height:25px;padding-bottom:2px;line-height:25px;cursor:pointer;color:#656565;font-weight:bold;margin-top:-5px;}
</code></pre>
