c# - 如何获取 HtmlGenericControl 的属性值?

标签 c# asp.net html htmlgenericcontrol

我这样创建 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/

相关文章:

html - 为什么使用显示 :hidden for text in HTML? 被认为是不好的做法

c# - 无法将新实例添加到泛型类中的泛型列表。为什么?

c# - 未找到数据源名称且未指定默认驱动程序

c# - 需要确定 ELMAH 是否正在记录未处理的异常或由 ErrorSignal.Raise() 引发的异常

c# - DataAnnotations问题

css - 如何使用 css 制作此导航栏?

html - 切换的容器应该向上移动其他容器

C# 附加信息 : Connection must be valid and open

c# - 如何使用 MySQL 配置流畅的 nHibernate

C# MVVM : Edit a SelectedItem of an ObservableCollection with a RelayCommand