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

Discussion in 'ASP .Net Web Controls' started by matthias s, Sep 20, 2007.

  1. matthias s

    matthias s Guest

    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
     
    matthias s, Sep 20, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mufasa
    Replies:
    7
    Views:
    431
    Alexey Smirnov
    Sep 4, 2007
  2. Belinda
    Replies:
    4
    Views:
    386
    Bob Barrows [MVP]
    Jun 11, 2004
  3. Replies:
    0
    Views:
    324
  4. Replies:
    4
    Views:
    554
    cwdjrxyz
    Jan 17, 2006
  5. mikew01

    Change form action then back again

    mikew01, Jan 15, 2009, in forum: Javascript
    Replies:
    1
    Views:
    157
    Thomas 'PointedEars' Lahn
    Jan 15, 2009
Loading...

Share This Page