我这样创建 HtmlGenericControl
:
HtmlGenericControl inner_li = new HtmlGenericControl("li");
inner_li.Attributes.Add("style", "list-style-type: none");
我怎样才能得到这个属性的值(style
)。
最佳答案
您可以使用索引器来完成:
var style = inner_li.Attributes["style"];
附带说明:在处理样式时,最好使用 HtmlControl.Style
属性:
inner_li.Style[HtmlTextWriterStyle.ListStyleType] = "none";
关于c# - 如何获取 HtmlGenericControl 的属性值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9496037/