Usercontrol dynamically loaded (in Init method of webcontrol) have viewstate problems

Discussion in 'ASP .Net' started by Matt Howeson, Mar 18, 2005.

  1. Matt Howeson

    Matt Howeson Guest

    I have a problem with a usercontrol that is dynamically loaded, from a web
    control and is not restoring it's viewstate properly.

    Here's the scenario. Within our content management system, I have a
    webcontrol which allows a admin user to select a usercontrol to include
    within a page when in "edit mode".

    When a user is editing the page they see a dropdown list of available
    controls and select one and save the page, kind of irrelevant to this
    problem but it gives some background.

    When the page is constructed to be served the webcontrol checks which
    usercontrol has been selected in it's Init method and adds the
    approprapriate usercontrol to the webcontrols' Controls collection.

    When the usercontrol is loaded dynamically it loads a repeater on the page,
    and it's contents should be stored in the viewstate. However when a
    postback is carried out the contents of any controls within the dynamically
    loaded usercontrol are lost.

    Any help or advice on this greatly appreciated. Please note the controls
    are loaded in the Init method of the webcontrol, so before the Loadviewstate
    method fires, and at the loadviewstate and saveviewstate methods are both
    being called for the dynamically loaded usercontrol.

    Thanks,

    Matt
     
    Matt Howeson, Mar 18, 2005
    #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. huobazi
    Replies:
    1
    Views:
    717
    David Waz...
    Jul 3, 2003
  2. S. Justin Gengo

    Re: Dynamically Loaded UserControl and ViewState

    S. Justin Gengo, Feb 17, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,791
    S. Justin Gengo
    Feb 17, 2004
  3. =?Utf-8?B?Q2FwdGFpbiBTZW5zaWJsZQ==?=

    Usercontrol derived from Usercontrol - masterpage init is fired tw

    =?Utf-8?B?Q2FwdGFpbiBTZW5zaWJsZQ==?=, Feb 3, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    469
    =?Utf-8?B?Q2FwdGFpbiBTZW5zaWJsZQ==?=
    Feb 3, 2006
  4. Tony Cheng
    Replies:
    1
    Views:
    8,258
    Juan T. Llibre
    Feb 24, 2006
  5. Luis Ramírez.

    Can a webcontrol (webcontrol.dll) have a configuration file?

    Luis Ramírez., Jul 5, 2004, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    208
    Luis Ramírez
    Jul 6, 2004
Loading...

Share This Page