5

I create HtmlGenericControl like this :

HtmlGenericControl inner_li = new HtmlGenericControl("li");
inner_li.Attributes.Add("style", "list-style-type: none");

How can i get the value of this attribue(style).

4

3 回答 3

9

You can do it using indexer:

var style = inner_li.Attributes["style"];

Just a side note: when dealing with styles it's better to use HtmlControl.Style property:

inner_li.Style[HtmlTextWriterStyle.ListStyleType] = "none";
于 2012-02-29T08:58:09.260 回答
2

The Attributes property is name value collection. So you can do string tempstr = inner_li.Attributes["style"].

See the msdn doc.

于 2012-02-29T08:54:44.200 回答
1

You can get the value using the below statement

string myvalue= inner_li.Attributes["style"];
于 2012-02-29T08:58:35.857 回答