Adding css class through aspx code behind

后端 未结 6 811
暖寄归人
暖寄归人 2020-12-08 13:13

I am using aspx. If I have HTML as follows:

I am hoping to dynamically add a css class through the

6条回答
  •  心在旅途
    2020-12-08 13:29

    Assuming your div has some CSS classes already...

    The following won't replace existing definitions:

    ClassMe.CssClass += " second";
    

    And if you are not sure until the very last moment...

    string classes = ClassMe.CssClass;
    ClassMe.CssClass += (classes == "") ? "second" : " second";
    

提交回复
热议问题