I'm writing a custom web control, using ParseControl quite a bit. Create a
new WebForm, with nothing in the form element. Then, add the following in
the Page_Load event handler.

Control panel = ParseControl("<asp:Panel id=\"Panel1\"
runat=\"server\"></asp:Panel>");
Control newctrl = ParseControl("<asp:TextBox id=\"TextBox1\"
runat=\"server\"></asp:TextBox>");
panel.Controls.Add(newctrl);
foreach (Control ctrl in this.Controls) {
    if (ctrl is HtmlForm) {
        ctrl.Controls.Add(panel);
    }
}

When the page renders, the textbox is not inside the resulting div! However,
if the line that creates the panel is changed to:

Control panel = new Panel();

Then the textbox is correctly placed inside the div element. What is going
on? ParseControl seems to work great, but for some reason I can't add child
controls to them. Does anyone have any ideas?

Thanks,
Erick

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to