用c#中与代码隐藏完全匹配的css类替换css类

用c#中与代码隐藏完全匹配的css类替换css类,c#,asp.net,C#,Asp.net,用c#中与代码隐藏完全匹配的css类替换css类。看起来btn1.CssClass.Replace()方法没有执行精确匹配。任何其他建议请…这是一个HtmlGenericControl,因此不确定推荐的方法是什么,因此您也可以这样做: testSpace.Attributes.Add("style", "text-align: center;"); 或 或 或 希望这有帮助,更清楚地解释您的问题。我正在动态更改css。btn1的css类字符串为“GreenButtonShortDisabled

用c#中与代码隐藏完全匹配的css类替换css类。看起来btn1.CssClass.Replace()方法没有执行精确匹配。任何其他建议请…

这是一个HtmlGenericControl,因此不确定推荐的方法是什么,因此您也可以这样做:

testSpace.Attributes.Add("style", "text-align: center;");


希望这有帮助,

更清楚地解释您的问题。我正在动态更改css。btn1的css类字符串为“GreenButtonShortDisabled divfloaleft”。当我编写以下代码btn1.CssClass.Replace(“GreenButtonShort”、“GreenButtonShortDisabled”);然后更改的css是“GreenbuttonShortDisabledDisabledDivFloAleft”。我想要全字匹配。我正在动态更改css。btn1的css类字符串为“GreenButtonShortDisabled divfloaleft”。当我编写以下代码btn1.CssClass.Replace(“GreenButtonShort”、“GreenButtonShortDisabled”);然后更改的css是“GreenbuttonShortDisabledDisabledDivFloAleft”。我要全词匹配
testSpace.Attributes.Add("class", "centerIt");
testSpace.Attributes["style"] = "text-align: center;";
testSpace.Attributes["class"] = "centerIt";