如何检查样式属性是否设置?

时间:2020-01-28 16:36:14

标签: c# webforms

我可以在代码后面的标签上加上下划线

Label1.Style.Add("text-decoration", "underline");

但是如何检查标签是否带下划线?像这样吗?

if(Label1.Style.Add("text-decoration") == "underline")
if(Label1.Style[HtmlTextWriterStyle.TextDecoration] == "underline")

两者都不起作用!

1 个答案:

答案 0 :(得分:0)

如果您需要测试某种样式并使用Web表单,建议您检查该特定样式的data属性。上面的D Stanley给出了以下代码片段,可用于检查布尔值。

Label1.Style["text-decoration"] == "underline"