Removing class from a div in c#

Total Post:154

Points:1086

C# 
C#
 5680  View(s)
Ratings:
Rate this:

I tried using the server-side .CssClass, but this isn't available for me to use. My div has runat="server" so I can access it, but I just cannot see .CssClass in the drop-down when i hit ".". Does anyone know how to get past this or any other solution that might work?


  1. Re: Removing class from a div in c#

    Hi Manoj,


    If you are wanting to read the class name, you will need to use the code:

    string className = Test.Attributes["class"].ToString();

    If you are wanting to replace a specific class you will need to use the code:

    Test.Attributes.Add("class", Test.Attributes["class"].ToString().Replace("spacerDiv", ""));

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.