|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
GrayHairDay: moving page controls to a form and then the form back to the page?first note that this code concerns .net framework 1.1. I'm having trouble with the following: I have a class derived from Page. In the Page_Load of this class I'd like to do the following: HtmlForm form = new HtmlForm(); form.Name = "test"; form.ID = form.Name; form.Controls.Add(_header); // user controls I've instanciated and loaded using LoadControl(...) form.Controls.Add(_menu); .... // add child controls from the derived page for(int i = 0; i < Page.Controls.Count; i++) { form.Controls.Add(Page.Controls[i]); } form.Controls.Add(_footer); Page.Controls.Clear(); Page.Controls.Add(form); What I'd like to achive is to have a base page with a couple of controls on, from which i can derive further. The problem I'm having is, that on each round in the for loop, when I "read" the Page.Control at the given index, the Page.Controls.Count decreases by one. Could somebody please shed some light. Thanks in advance! Greetings from Berlin, Matthias |
|||||||||||||||||||||||