Displaying CSS properties and values of a HtmlControl
I have a <div id="Result" ... >
with a bunch of CSS properties and values and I would like to display them when I click a button. This is what I currently have:
protected void Button1_OnServerClick(object sender, EventArgs e)
{
for (int i = 0; i < Result.Style.Value.Length; i++)
{
Result.InnerHtml += Result.Style.Value[i];
}
}
The code does display them, however, they are all displayed in a sequence of characters. I would like to开发者_开发知识库 get them displayed as properties and values, both with different accessing variable and all pairs on seperate row.
I messed with it for a good while but I can not figure it out.
Loop through the Keys collection:
protected void Button1_Click(object sender, EventArgs e)
{
foreach (String key in Result.Style.Keys)
{
Result.InnerHtml += key + ": " + Result.Style[key] + ";</br>";
}
}
精彩评论