Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize the appearance of ASP.Net Login control?

Tags:

c#

asp.net

I want to style ASP.Net Login control.

<asp:Login ID="login" runat="server" DisplayRememberMe="false" 
   onloggedin="LogIn_LoggedIn">
</asp:Login>

I would like to expand it to view all the table cells and such.

like image 975
user3410846 Avatar asked Dec 29 '25 10:12

user3410846


1 Answers

In designer view, you can convert the Login control to Template.

enter image description here

It'll create the following code for you. Note: Make sure you do not rename controls' ID.

<asp:Login ID="login" runat="server" DisplayRememberMe="false"
    OnLoggedIn="LogIn_LoggedIn">
    <LayoutTemplate>
        <table cellpadding="1" cellspacing="0" style="border-collapse:collapse;">
            <tr>
                <td>
                    <table cellpadding="0">
                        <tr>
                            <td align="center" colspan="2">Log In</td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="UserName" runat="server"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="login">*</asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="login">*</asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="center" colspan="2" style="color:Red;">
                                <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" colspan="2">
                                <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="login" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </LayoutTemplate>
</asp:Login>
like image 58
Win Avatar answered Dec 31 '25 00:12

Win