protected override void Render(HtmlTextWriter writer)
{
HtmlGenericControl div1 = new HtmlGenericControl("div");
div1.Attributes.Add("class", "modalbox");
if (!ClientVisible)
div1.Attributes.CssStyle.Add("display", "none");
HtmlGenericControl div2 = new HtmlGenericControl("div");
div2.Attributes.Add("class", "modalbox-m1");
HtmlGenericControl div3 = new HtmlGenericControl("div");
div3.Attributes.Add("class", "modalbox-m2");
foreach (Control c in this.Controls)
div3.Controls.Add(c); // exception here
div2.Controls.Add(div3);
div1.Controls.Add(div2);
div1.RenderControl(writer);
}
我无法理解WHO和WHERE变更this.Controls
?为什么在PlaceHolder.Controls上抛出“Collection被修改”?
倍率的'CreateChildControls'方法和放置上面的代码,并检查 – Damith