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