Search code examples
asp.netcolorstextboxlabel

ASP Textbox Label Font Color


I'm looking to change the font color of an ASP label applied to a textbox and am unsure of what property to use. In what I've shown below, I want to change the font color of "Student Search: " because I believe the default is black, but the label is on top of a black background and so I cannot currently see it.

<asp:Label id="label" AssociatedControlId="masterSearchBox" Text="Student Search: " 
    runat="server"/>

<asp:TextBox id="masterSearchBox" runat="server" placeholder="Enter Student Name..."/>

Solution

  • You should use CSS classes for controlling font colors and what have you. In your css file, put a class name and make sure that css file is referenced by your asp page.

    .YourClassName {
    color: white;
    }
    <asp:Label id="label" AssociatedControlId="masterSearchBox" Text="Student Search: " 
        runat="server" CssClass="YourClassName" />