0
我是newbiesin webform。我想在Webform頁面中呈現「UserControl1」。然後在「UserControl1」中,我將一個列表分配給其具有「asp:Repeater」模板的子用戶控件(「UserControl2」)。 「UserControl2」中的DOM除「asp:Repeater」已渲染外。無法渲染包含重複項目的子控件?
網絡表單頁面:
protected override void OnPreRender(EventArgs e)
{
var control1 = (WebUserControl1)Page.LoadControl("~/WebUserControl1.ascx");
HtmlTextWriter htmlwriter = new HtmlTextWriter(new StringWriter());
control1.ControlRender();
control1.RenderControl(htmlwriter);
string html = htmlwriter.InnerWriter.ToString();
base.OnPreRender(e);
}
UseContrl1:
public void ControlRender()
{
OnPreRender(null);
}
protected override void OnPreRender(EventArgs e)
{
List<string> list=new List<string> {"1", "2", "3"};
usecontrol2.Products = list;
}
在此先感謝。