I’m using a CSS file for styling, and it’s working properly for all of my controls except for a label on my page. It’s the only label on the page, so maybe it’s a problem w/ labels in general? I’m changing the Label.Text property several times, and the text gets updated properly every time, but it’s just raw, non-styled text.
I have the following style listed in my CSS file:
label.myError { font-weight:bold; font-size: 25px; color:Red; font-family: Arial }
I have the following label control on my web page:
<asp:Label ID="lblError" CssClass="myError" runat="server" />
Then, at various points in my code-behind, I change the Text on the Label like this:
lblError.Text = "Please specify a " + fieldDescription + ".";
asp.net label renders as
spanand notlabelhtml element. Your css specifies that the class should work with labels onlyyou just have to change
label.myErrorto.myErrorto be likeand isA it will work.