开发者

Displaying CSS properties and values of a HtmlControl

开发者 https://www.devze.com 2023-03-28 23:57 出处:网络
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:

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>";
        }
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消