开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜