HOW TO GET ACCESS TO “CSSCLASS” PROPERTY FOR SERVER ELEMENT ISN'T WEBCONTROL IN ASP.NET?

Hugh Jackman

Total Post:52

Points:366
Posted by  Hugh Jackman
 1015  View(s)
Ratings:
Rate this:

I have ordinary div like this:

<div id="myCoolElement" runat="server"></div>

I want use the construction to set CssClass for myCoolElement like this:

myCoolElement.CssClass("mycoolstyle");

But CssClass property is supported only for WebControls.

How I can set CssClass for my element without creating WebControl?

  1. jacob rasel

    Post:88

    Points:616
    Re: How to get access to “CssClass” property for server element isn't WebControl in ASP.NET?

    You can do like this

     

    myCoolElement.Attributes["class"] = "mycoolstyle";

  1. Mark Devid

    Post:102

    Points:714
    Re: How to get access to “CssClass” property for server element isn't WebControl in ASP.NET?

    Try this.

     myCoolElement.Attributes.Add("class", "mycoolstyle");

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!