开发者

Change CSS on span tag in ASP.NET Web Forms

开发者 https://www.devze.com 2023-02-21 11:08 出处:网络
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开发者_如何学Go it a type of HTMLGenericControl but cannot get the CssClass tag to popup in IntelliS

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开发者_如何学Go 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 :-)

0

精彩评论

暂无评论...
验证码 换一张
取 消