using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; namespace Ascxcontrol.Controls { public partial class controlone : System.Web.UI.UserControl { //Literal1.Text = RenderUserControlToString("../Controls/controltwo.ascx"); private string RenderUserControlToString(string ucpath) { UserControl uc = (UserControl)this.LoadControl(ucpath); using (TextWriter tw = new StringWriter()) using (HtmlTextWriter htw=new HtmlTextWriter(tw)) { uc.RenderControl(htw); return tw.ToString(); } } protected void Page_Load(object sender, EventArgs e) { for (int i = 0; i < 10; i++) { controltwo ct = (controltwo)this.LoadControl("../Controls/controltwo.ascx"); ct.Text = i.ToString(); PlaceHolder1.Controls.Add(ct); } } } }