How to change attributes of elemnet class in C #

I have this class

.progress {

    width:200px;
    height:50px;
    border:1px solid black;
    position:relative;
}
.progress:after {

   position:absolute;
    background:black;
    top:0; bottom:0;
    left:0; 
    width:10%;
    -webkit-animation: filler 2s ease-in-out;
    -moz-animation: filler 2s ease-in-out;
    animation: filler 2s ease-in-out;
}

      

and this div

<div id="percentDIV" class="progress" runat="server">some text</div>

      

I want to change the width progress: attribute after the class in C # dynamically. Is it possible?

something like?

percentDIV.Attributes["class:progress:after"] = "width:25%";

      

+3


source to share


2 answers


Declare your next div to runat="server"

and change its style

  percentDiv.Attributes["style"] = "width:20%";

      



Styles take precedence over classes.

Another way is to remove the class declaration from the CSS and dynamically create it in the header section of the page using the control runat="server"

, replacing its content with the dynamically generated css class.

+1


source


percentDIV.Attributes["style"] = "width:20%";

      



0


source







All Articles