如何将一个div添加到div容器在c#code背后 [英] how to add a div to container div in c# code behind
本文介绍了如何将一个div添加到div容器在c#code背后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ASP.NET,C#
ASP.NET, C#
正如标题我想知道是否有人知道如何编程(C#$隐藏文件C $ C)一个div添加到另一个容器格(在aspx页面)。
As the title suggests I was wondering if anyone knew how to programatically (c# code behind file) add a div to another a container div (in the aspx page).
在此先感谢
推荐答案
//创建的分区新实例,并设置所有的值,如ID 退房短code例子。它的工作对我来说,在Web创建的div添加
//create new instance of div and set all the values like the ID Check out the short Code example. It worked for me to create Divs in a web add
System.Web.UI.HtmlControls.HtmlGenericControl NewDiv = new
System.Web.UI.HtmlControls.HtmlGenericControl();
NewDiv.ID = "divcreated";
或
protected void Page_Load(object sender, EventArgs e)
{
System.Web.UI.HtmlControls.HtmlGenericControl createDiv =
new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
createDiv.ID = "createDiv";
createDiv.Style.Add(HtmlTextWriterStyle.BackgroundColor, "Yellow");
createDiv.Style.Add(HtmlTextWriterStyle.Color, "Red");
createDiv.Style.Add(HtmlTextWriterStyle.Height, "100px");
createDiv.Style.Add(HtmlTextWriterStyle.Width, "400px");
createDiv.InnerHtml = " I'm a div, from code behind ";
this.Controls.Add(createDiv);
}
这篇关于如何将一个div添加到div容器在c#code背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文