1

我从 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);
}

但是渲染的列表有项目符号,我想阻止它们。

4

3 回答 3

21

使用 CSS:

ul {
   list-style: none;
}
于 2012-12-21T15:52:43.800 回答
5

我认为您可以使用 style 属性:

list.Style.Add("list-style", "none");
于 2012-12-21T15:55:25.863 回答
0

你不能在类似的东西上加上一个id名称: HtmlGenericControl list = new HtmlGenericControl("ul"); list.Id = "myId";

然后在css中定义:

#myId{
 list-style-type: none;
}
于 2012-12-21T15:54:42.713 回答