Search code examples
c#asp.netasp.net-membershipmembership-provider

How to change the value of Login Control's FailureText on post back


I am trying to change FailureText of Login control is IsApproved = false. But unable to do so. In watch it shows the text change when breakpoint hits the if condition. But when the page loads, it show the original result. Any suggestions please.

<asp:Login ID="LoginControl" runat="server" MembershipProvider="Xrm" 
      FailureText="Unable to login, please check your username and password"
                FailureTextStyle-CssClass="alert alert-error" RenderOuterTable="False">

</asp:Login>

<%
if (IsPostBack && !Membership.GetUser(LoginControl.UserName).IsApproved)
{
    LoginControl.FailureText = "Account is locked, please try after 10 minutes.";
}                
 %>

enter image description here

Thanks in advance


Solution

  • Created the LoginError event to move the IF condition there and it started working.

    protected void LoginControl_LoginError(object sender, EventArgs e)
    {}