GrayHairDay: moving page controls to a form and then the form back to the page?

M

matthias s

Hello,

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);
}

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top