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);
}
}
}
}

 

  感谢:csdn   insus

相关文章:

  • 2022-12-23
  • 2021-12-28
  • 2021-10-24
  • 2022-12-23
  • 2021-07-29
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-22
  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2021-08-26
  • 2021-12-11
相关资源
相似解决方案