[英]How to remove Html <li> bullets from codebehind?
我从codebehind创建一个html列表,如下所示:
HtmlGenericControl list = new HtmlGenericControl("ul");
for (int i = 0; i < 10; i++)
{
HtmlGenericControl listItem = new HtmlGenericControl("li");
Label textLabel = new Label();
textLabel.Text = "Menu"+i;
listItem.Controls.Add(textLabel);
list.Controls.Add(listItem);
}
但是呈现的列表中有项目符号,我想防止它们。
使用CSS:
ul {
list-style: none;
}
我认为您可以使用style属性:
list.Style.Add("list-style", "none");
您是否可以像这样输入id名称: HtmlGenericControl list = new HtmlGenericControl("ul"); list.Id = "myId";
HtmlGenericControl list = new HtmlGenericControl("ul"); list.Id = "myId";
然后在css中定义:
#myId{
list-style-type: none;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.