How to set background color of Login control in ASP.NET 2.0?

H

Hardy Wang

Hi all,
I have a login control, like below

<asp:Login ID="loginPanel" runat="server" BorderPadding="0"
PasswordRecoveryText="Click to retrieve your password"
TitleText="Enter Your Username & Password to Login">
<LabelStyle CssClass="ItemCaption" />
<TitleTextStyle CssClass="ItemCaptionLong" />
<CheckBoxStyle CssClass="Item" />
<TextBoxStyle BackColor="#E0E0E0" Width="150px" />
</asp:Login>

I set CSS classes to Label, TitleText and CheckBox. All these styles set the
background color of the <TD> with these controls (because it eventually turn
to <TD class="Item"> in HTML). But I find no way to set the background color
of <TD> with two textboxes, in another word, the CssClass can only be set to
<input ....> instead of <TD>.

Is there anybody who has some solution?

Regards
Hardy
 
J

Joshua Flanagan

You can get more fine-grained control over the HTML rendering by using
the LayoutTemplate tag.

If you are using VS2005, go to Design view, and use the SmartTag on the
Login control and choose "Convert to template".

Otherwise, you will have to build the LayoutTemplate yourself. I've
included the default template that was created by VS2005 with your login
control.

Joshua Flanagan
http://flimflan.com/blog



<LayoutTemplate>
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse">
<tr>
<td>
<table border="0" cellpadding="0">
<tr>
<td align="center"
class="ItemCaptionLong" colspan="2">
Enter Your Username &amp;
Password to Login</td>
</tr>
<tr>
<td align="right"
class="ItemCaption">
<asp:Label
ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User
Name:</asp:Label></td>
<td>
<asp:TextBox ID="UserName"
runat="server" BackColor="#E0E0E0" Width="150px"></asp:TextBox>
<asp:RequiredFieldValidator
ID="UserNameRequired" runat="server" ControlToValidate="UserName"
ErrorMessage="User Name
is required." ToolTip="User Name is required."
ValidationGroup="loginPanel">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right"
class="ItemCaption">
<asp:Label
ID="PasswordLabel" runat="server"
AssociatedControlID="Password">Password:</asp:Label></td>
<td>
<asp:TextBox ID="Password"
runat="server" BackColor="#E0E0E0" TextMode="Password"

Width="150px"></asp:TextBox>
<asp:RequiredFieldValidator
ID="PasswordRequired" runat="server" ControlToValidate="Password"
ErrorMessage="Password
is required." ToolTip="Password is required."
ValidationGroup="loginPanel">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="Item" colspan="2">
<asp:CheckBox
ID="RememberMe" runat="server" Text="Remember me next time." />
</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="loginPanel" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:HyperLink
ID="PasswordRecoveryLink" runat="server">Click to retrieve your
password</asp:HyperLink>
</td>
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top