Adding a Dynamic User Control from the Base Page Class (and retaining it on Postback?)

Discussion in 'ASP .Net Building Controls' started by David Bowey, Mar 10, 2005.

  1. David Bowey

    David Bowey Guest

    Hi There!

    As the subject says, I need to add a user control dynamically (using
    LoadControl function) to the derieved page from the base Page class and I
    want the added contol to be retained on PostBack as well as retain its'
    state (such as properties).

    How do I acoomplish this?

    Thank you all in advance.
    Dave
     
    David Bowey, Mar 10, 2005
    #1
    1. Advertising

  2. David Bowey

    Guest

    If possible create the control in the OnInit each time. Make sure you
    give it a Unique ID. If you do both of these I believe the ViewState
    should be handled for you automatically
     
    , Mar 10, 2005
    #2
    1. Advertising

  3. I think it is also pretty important that you add the control in to the
    controls collection before ammending any of its properties:

    i.e.
    dim txtAAA as textbox
    txtAAA = new textbox
    txtAAA.id = "txtAAA"
    txtAAA.text = "BBB" '<-- I don't think that this text property would be
    tracked by the viewstate
    me.controls.add(txtAAA)
    txtAAA.text = "AAA" <-- whereas this one would....




    "David Bowey" <> wrote in message
    news:%...
    > Hi There!
    >
    > As the subject says, I need to add a user control dynamically (using
    > LoadControl function) to the derieved page from the base Page class and I
    > want the added contol to be retained on PostBack as well as retain its'
    > state (such as properties).
    >
    > How do I acoomplish this?
    >
    > Thank you all in advance.
    > Dave
    >
    >
     
    Nick Stansbury, Apr 5, 2005
    #3
    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. Jeremy Jones
    Replies:
    4
    Views:
    1,357
    Jeremy Jones
    Dec 14, 2006
  2. mirin
    Replies:
    1
    Views:
    888
    Mark Rae [MVP]
    Mar 3, 2008
  3. Etrast

    Dynamic Template Column - retaining value on postback

    Etrast, Jun 17, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    331
    Tim_k
    Jun 30, 2004
  4. Etrast

    Dynamic Template Column - retaining value on postback

    Etrast, Jun 17, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    260
    Andy Z Smith
    Jun 17, 2004
  5. David Bowey
    Replies:
    2
    Views:
    217
    Nick Stansbury
    Apr 5, 2005
Loading...

Share This Page