Remove a CSS class from HTML element in the code behind file

后端 未结 7 2171
清歌不尽
清歌不尽 2021-02-19 03:15

I have the following on my interface / webform:

Now I have a condition in my

7条回答
  •  耶瑟儿~
    2021-02-19 03:45

    public static void appendCssClass(HtmlGenericControl htmlGenericControl, string cssClassName)
        {
            htmlGenericControl.Attributes.Add("class", 
                htmlGenericControl.Attributes["class"].ToString() + " " + cssClassName);
        }
    
        public static void removeCssClass(HtmlGenericControl htmlGenericControl, string cssClassName)
        {
            htmlGenericControl.Attributes.Add("class",
                        htmlGenericControl.Attributes["class"].Replace(cssClassName, ""));
        }
    

提交回复
热议问题