troubleshooting Question

Need to display image beside failure message when login does not go through

Avatar of mathieu_cupryk
mathieu_cuprykFlag for Canada asked on
ASP.NET
19 Comments1 Solution414 ViewsLast Modified:
Not sure how to get this working.  

      protected void LoginStatus_LoggingIn1(object sender, LoginCancelEventArgs e)
        {
            if (loginUser == null)
            {
                var lgnMain = ((Login)LoginView1.FindControl("LoginStatus"));
                string username = lgnMain.UserName;

                loginUser = Membership.GetUser(username);
            }
            var imageError = ((Image)LoginView1.FindControl("ImageError"));

            imageError.ImageUrl = "~/Images/Icons/alert.gif";

        }
<asp:Login ID="LoginStatus" runat="server" Height="31px" Width="100%" 
            estinationPageUrl="~/Secure/UserProfile.aspx" 
            onloggingin="LoginStatus_LoggingIn1">
            <LayoutTemplate>
                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                        <td nowrap="nowrap" width="25%">
                            <asp:Label runat="server" ID="lblUserName" AssociatedControlID="UserName" Text="Username:" />
                            <asp:TextBox ID="UserName" runat="server" BorderColor="DarkGray" BorderStyle="Inset"
                                BorderWidth="2px" Width="125px" />&nbsp;
                        </td>
                        <td width="8px" style="text-align: left;" valign="middle">
                            <asp:RequiredFieldValidator ID="valRequireUserName" runat="server" SetFocusOnError="True"
                                ControlToValidate="UserName" Text="*" ValidationGroup="Login" Font-Bold="True" />
                        </td>
                        <td nowrap="nowrap" width="25%">
                            <asp:Label ID="lblPassword" runat="server" AssociatedControlID="Password" Text="Password:" />
                            <asp:TextBox ID="Password" runat="server" TextMode="Password" BorderColor="DarkGray"
                                BorderStyle="Inset" BorderWidth="2px" Width="125px" />&nbsp;
                        </td>
                        <td width="8px" style="text-align: left;" valign="middle">
                            <asp:RequiredFieldValidator ID="valRequirePassword" runat="server" ControlToValidate="Password"
                                SetFocusOnError="True" Text="*" ValidationGroup="Login" Font-Bold="True" />
                        </td>
                        <td width="25%">
                            <asp:Button CssClass="button-login" ValidationGroup="Login" CommandName="Login" ID="btnLogin"
                                runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td width="100%" colspan="5" style="text-align: right;">
                            <asp:HyperLink ID="lnkRegister" runat="server" NavigateUrl="~/Secure/Register.aspx">Create New Account 
                            </asp:HyperLink>
                            |
                            <asp:HyperLink ID="lnkPasswordRecovery" runat="server" NavigateUrl="~/Secure/PasswordRecovery.aspx">Forgot 
                                password?</asp:HyperLink>
                        </td>
                    </tr>
                    <tr>
                        <td width="100%" colspan="5" style="text-align: right;">
                            <asp:Image id="ImageError" runat="server" Width="24" Height="18" src=""  />
                            <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
                            <input type="text" name="theTime" size="30" readonly="readonly" style="border: 0px;
                                margin-left: 4px; font-weight: bold;">
                        </td>
                    </tr>
                </table>
            </LayoutTemplate>
        </asp:Login>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 19 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 19 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros