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>
Have you tried:
collegeSpan.Attributes["class"] = "foo";
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 :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With