REMOVING CLASS FROM A DIV IN C#

Manoj Bhatt

Total Post:154

Points:1086
Posted by  Manoj Bhatt
C# 
C#
 4618  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. Pravesh Singh

    Post:412

    Points:2888
    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

NEWSLETTER

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