私はこのようなHtmlGenericControl
を作成します。どのようにしてHtmlGenericControlの属性値を取得できますか?
HtmlGenericControl inner_li = new HtmlGenericControl("li");
inner_li.Attributes.Add("style", "list-style-type: none");
どのように私はこのattribue(style
)の値を取得することができます。
私はこのようなHtmlGenericControl
を作成します。どのようにしてHtmlGenericControlの属性値を取得できますか?
HtmlGenericControl inner_li = new HtmlGenericControl("li");
inner_li.Attributes.Add("style", "list-style-type: none");
どのように私はこのattribue(style
)の値を取得することができます。
あなたはインデクサを使用してそれを行うことができます。
var style = inner_li.Attributes["style"];
ちょうどサイドノート:スタイルを扱うとき、それはHtmlControl.Style
プロパティを使用することをお勧めします:
inner_li.Style[HtmlTextWriterStyle.ListStyleType] = "none";
ザ・プロパティ属性は名前と値のコレクションです。だからあなたは string tempstr = inner_li.Attributes["style"]
することができます。
はmsdn docを参照してください。
あなたは、以下のステートメントを使用して値を取得することができます
string myvalue= inner_li.Attributes["style"];
'inner_li.Attributes [" style "]' .thanks alot –