2 Questions (Viewstate and ChildControlsCreated=false)

Discussion in 'ASP .Net Web Controls' started by Steve Drake, Nov 11, 2003.

  1. Steve Drake

    Steve Drake Guest

    All,

    I have 2 Questions, I want to save some custom information to the viewstate,
    I cannot do this via the usual property get and set I override the
    LoadViewState and SaveViewState, is this a good idea?

    code :

    protected override void LoadViewState(object savedState)
    {
    base.LoadViewState (savedState);

    if (ViewState["CurrentSearch"] != null)
    {
    currentSearch = (AdvancedSearchItemCollection)
    ViewState["CurrentSearch"] ;
    }
    else
    {
    currentSearch = new AdvancedSearchItemCollection();
    }
    }
    protected override object SaveViewState()
    {
    ViewState["CurrentSearch"] = currentSearch;
    return base.SaveViewState ();
    }

    It does work, but I was unsure if this was a bad way todo this.

    Also... If a server event needs to change what controls are created, is it
    good pratise to set ChildControlsCreated to false? I've used this mehod
    loads as the CreateChildControls gets run before the events, setting
    ChildControlsCreated to false cause the CreateChildControls to get re-run,
    again is this a good idea, if not what alternitives do I have.

    Steve
     
    Steve Drake, Nov 11, 2003
    #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. André
    Replies:
    3
    Views:
    1,603
  2. Rajarshi

    0 == False but [] != False?

    Rajarshi, May 24, 2007, in forum: Python
    Replies:
    20
    Views:
    712
    Erik Max Francis
    May 30, 2007
  3. DJ
    Replies:
    3
    Views:
    940
  4. trans.  (T. Onoma)
    Replies:
    0
    Views:
    156
    trans. (T. Onoma)
    Sep 25, 2004
  5. trans.  (T. Onoma)
    Replies:
    1
    Views:
    169
    David A. Black
    Sep 25, 2004
Loading...

Share This Page