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 cannot do this. I tried giving it an HTMLGenericControl type, but cannot get the CssClass tag for the popup in IntelliSense.

 <span id="collegeSpan" runat="server" class="college">other code here</span> 
+4
source share
2 answers

You tried:

 collegeSpan.Attributes["class"] = "foo"; 
+7
source

If you can modify HTML / ASCX, use asp:Label instead of span . The asp:Label element appears as span on the page, but it has several advantages, including the ability to change the CssClass property.

+5
source

Source: https://habr.com/ru/post/1346128/


All Articles