Nothing happen when adding Errors to error msg of LoginControl
<p>I had a Login.aspx page. I want to replace the original error message so that user can know what they had wrongly input into the Login Control. </p>

<p>Despite adding all the related codes and checking through my Login.aspx.cs file, and test run it, the default message keep appearing instead of the code that I had added.</p>

<p>Default message: </p>

<pre><code>"Your login attempt was not successful. Please try again"
</code></pre>

<p>Seems that the code that I wrote didn't executed. And I had not know what was wrong at it. </p>

<p>Here is my Login.aspx.cs code: </p>

<pre><code>protected void Login1_LoginError(object sender, System.EventArgs e)
{

        System.Web.UI.WebControls.Login Login1 = (System.Web.UI.WebControls.Login)LoginView1.FindControl("Login1");
        TextBox UserName = (TextBox)Login1.FindControl("UserName");
        Literal FailureText = (Literal)Login1.FindControl("FailureText");

    //There was a problem logging in the user
    //See if this user exists in the database

    MembershipUser userInfo = Membership.GetUser(UserName.Text);
    if (userInfo == null)
    {
        //The user entered an invalid username...

        FailureText.Text = "There is no user in the database with the username " + UserName.Text;
    }
    else
    {
        //See if the user is locked out or not approved
        if (!userInfo.IsApproved)
        {
            FailureText.Text = "When you created your account you were sent an email with steps to verify your account. You must follow these steps before you can log into the site.";
        }
        else if (userInfo.IsLockedOut)
        {
            FailureText.Text = "Your account has been locked out because of a maximum number of incorrect login attempts. You will NOT be able to login until you contact a site administrator and have your account unlocked.";
        }
        else
        {
            //The password was incorrect 
            FailureText.Text = "Invalid Password. Please try again." ;
        }
    }
}
</code></pre>

<p>Can anyone help me suggestions what was wrong with the code? 
My Login control was build inside LoginView. 
Thanks!</p>

<p>*<em>Update: Login code *</em></p>

<pre><code>&lt;asp:LoginView ID="LoginView1" runat="server" &gt;

&lt;AnonymousTemplate&gt; 
    &lt;asp:Login ID="Login1" runat="server" DestinationPageUrl="~/Login.aspx" 
        onloginerror="Login1_LoginError"&gt;
        &lt;LayoutTemplate&gt;
            &lt;table cellpadding="1" cellspacing="0" style="border-collapse:collapse;"&gt;
                &lt;tr&gt;
                    &lt;td&gt;
                        &lt;table cellpadding="0"&gt;
                            &lt;tr&gt;
                                &lt;td align="center" colspan="2"&gt;
                                    Log In&lt;/td&gt;
                            &lt;/tr&gt;
                            &lt;tr&gt;
                                &lt;td align="right"&gt;
                                    &lt;asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName"&gt;User Name:&lt;/asp:Label&gt;
                                &lt;/td&gt;
                                &lt;td&gt;
                                    &lt;asp:TextBox ID="UserName" runat="server"&gt;&lt;/asp:TextBox&gt;
                                    &lt;asp:RequiredFieldValidator ID="UserNameRequired" runat="server" 
                                        ControlToValidate="UserName" ErrorMessage="User Name is required." 
                                        ToolTip="User Name is required." ValidationGroup="ctl02$Login1"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                                &lt;/td&gt;
                            &lt;/tr&gt;
                            &lt;tr&gt;
                                &lt;td align="right"&gt;
                                    &lt;asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password"&gt;Password:&lt;/asp:Label&gt;
                                &lt;/td&gt;
                                &lt;td&gt;
                                    &lt;asp:TextBox ID="Password" runat="server" TextMode="Password"&gt;&lt;/asp:TextBox&gt;
                                    &lt;asp:RequiredFieldValidator ID="PasswordRequired" runat="server" 
                                        ControlToValidate="Password" ErrorMessage="Password is required." 
                                        ToolTip="Password is required." ValidationGroup="ctl02$Login1"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                                &lt;/td&gt;
                            &lt;/tr&gt;
                            &lt;tr&gt;
                                &lt;td colspan="2"&gt;
                                    &lt;asp:CheckBox ID="RememberMe" runat="server" Text="Remember me next time." /&gt;
                                &lt;/td&gt;
                            &lt;/tr&gt;
                            &lt;tr&gt;
                                &lt;td align="center" colspan="2" style="color:Red;"&gt;
                                    &lt;asp:Literal ID="FailureText" runat="server"&gt;&lt;/asp:Literal&gt;
                                &lt;/td&gt;
                            &lt;/tr&gt;
                            &lt;tr&gt;
                                &lt;td align="right" colspan="2"&gt;
                                    &lt;asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" 
                                        ValidationGroup="ctl02$Login1" /&gt;
                                &lt;/td&gt;
                            &lt;/tr&gt;
                        &lt;/table&gt;
                    &lt;/td&gt;
                &lt;/tr&gt;
            &lt;/table&gt;
        &lt;/LayoutTemplate&gt;
    &lt;/asp:Login&gt;   
    &lt;asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Default.aspx"&gt;Register&lt;/asp:HyperLink&gt;
&lt;/AnonymousTemplate&gt;

&lt;LoggedInTemplate&gt; 
Hello, &lt;asp:LoginName runat="server"&gt;&lt;/asp:LoginName&gt;
    &lt;asp:LoginStatus ID="LoginStatus1" runat="server" /&gt;

&lt;/LoggedInTemplate&gt;

&lt;/asp:LoginView&gt;
</code></pre>
