0

I need to append a div (with is content), after all tags with a specific css class (or data- tag) in code behind of asp.net c#.

Someone can help me? Basically it should work as "append" in jquery. I searched online but could not find anything, especially to "append" to a tag with a specific CSS class.

Thank you.

4

1 回答 1

1

您可以从后面的代码中添加一个 Diva 作为 html 通用控件

例如我有一个这样的 div

<div id="test" runat="server">Some Content</div>

当我指定 runat 服务器时,它将在那里可用,我可以添加这样的内容

HtmlGenericControl div= HtmlGenericControl();
div.TagName = "div"; //specify the tag here
//then specify the attributes
div.Attributes["height"] = "100%";
div.Attributes["width"] = "100%";
div.Attributes["class"] = "someclass";
div.Attributes["id"] = "someid";
test.Controls.Add(div);
于 2013-10-16T10:17:03.493 回答