ViewState Problem in Custom Control

Discussion in 'ASP .Net Web Controls' started by Nathan Brady, Jan 6, 2005.

  1. Nathan Brady

    Nathan Brady Guest

    I've developed a control that itself generates child controls dynamically,
    and everything works great, including capturing events from child controls,
    child controls maintaining their own view state, etc.

    My one problem is that any values I add to the ViewState dictionary (I'm
    currently adding them in my Page_Load handler) do not survive the postback.
    They simply disappear. My control derives from WebControl (which is a
    requirement), and everything I can find leads me to believe I should be able
    to use ViewState without additional code to save/load it.

    As a test, I tried to manually mess with overriding SaveViewState and
    LoadViewState. For some reason, the object passed to LoadViewState was always
    null.

    TIA,
    Nathan
     
    Nathan Brady, Jan 6, 2005
    #1
    1. Advertising

  2. Nathan,
    if you've overridden the viewstate handling at the control level, and come
    up with a null viewstate collection, perhaps the viewstate is turned off at
    the page/control level or the .config file level. if that's not the case,
    make sure you're calling the base.SaveViewState() method of you're overriden
    viewstate handler...

    Mike

    "Nathan Brady" <Nathan > wrote in message
    news:...
    > I've developed a control that itself generates child controls dynamically,
    > and everything works great, including capturing events from child

    controls,
    > child controls maintaining their own view state, etc.
    >
    > My one problem is that any values I add to the ViewState dictionary (I'm
    > currently adding them in my Page_Load handler) do not survive the

    postback.
    > They simply disappear. My control derives from WebControl (which is a
    > requirement), and everything I can find leads me to believe I should be

    able
    > to use ViewState without additional code to save/load it.
    >
    > As a test, I tried to manually mess with overriding SaveViewState and
    > LoadViewState. For some reason, the object passed to LoadViewState was

    always
    > null.
    >
    > TIA,
    > Nathan
    >
     
    Mike MacMillan, Jan 9, 2005
    #2
    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. Walter
    Replies:
    0
    Views:
    332
    Walter
    Oct 11, 2006
  2. Matt Sokol
    Replies:
    2
    Views:
    409
    Theo Tillotson
    Aug 7, 2003
  3. Josema
    Replies:
    2
    Views:
    364
  4. whoisnidhee

    ViewState of the Composite Control composed of custom control

    whoisnidhee, Jul 14, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    328
    Nidhee
    Jul 16, 2004
  5. Josema
    Replies:
    0
    Views:
    214
    Josema
    May 9, 2005
Loading...

Share This Page