Zeeshan Raja
Zeeshan Raja

Reputation: 145

Change CSS on span tag in ASP.NET Web Forms

I am trying to change the CSS for a span tag using C# but I am unable to do so. I have tried to give it a type of HTMLGenericControl but cannot get the CssClass tag to popup in IntelliSense.

<span id="collegeSpan" runat="server" class="college">other code here</span>

Upvotes: 4

Views: 9040

Answers (2)

Kornelis
Kornelis

Reputation: 101

Because a late answer is better then no answer at all, for the record: If you're able to alter the HTML/ASCX; use the asp:Label-control instead of a span. Label-controls are rendered to the page as a span, but it has some advantages, including the possibility to alter the "CssClass"-property :-)

Upvotes: 5

Darin Dimitrov
Darin Dimitrov

Reputation: 1039588

Have you tried:

collegeSpan.Attributes["class"] = "foo";

Upvotes: 7

Related Questions