在后台动态创建控件

后台代码

int i;
for(i=0;i<4;i++)
{
Control myUserControl;
myUserControl=Page.LoadControl("../UserControl/newsList.ascx");
PlaceHolder1.Controls.Add(myUserControl);
System.Web.UI.LiteralControl LC=new LiteralControl("<br>");
PlaceHolder1.Controls.Add(LC);
}

前台代码:

<placeholder id="PlaceHolder1" runat="server"><form id="Form1" method="post" runat="server"><font face="宋体"><placeholder id="PlaceHolder1" runat="server">&lt;form id="Form1" method="post" runat="server"&gt;<br>&lt;FONT face="宋体"&gt;<br>&lt;asp:PlaceHolder id="PlaceHolder1" runat="server"/&gt;<br>&lt;/FONT&gt;<br>&lt;/form&gt;</placeholder></font></form></placeholder>

你可能感兴趣的:(UI,Web,asp)