Persisting child controls

Discussion in 'ASP .Net' started by Alexandre Soares, Jun 4, 2004.

  1. Hi,

    I've made a collapsible panel custom control. It's pretty simple so far, it
    extends the Panel class and renders a bar above itself (panel) to show/hide
    the <div> of the panel on the client-side using DHTML. So far it works fine.

    I want to be able to make it work server-side as well: only the topbar is
    rendered if the panel is to be collapsed and the topbar AND the panel are
    rendered if the panel is to be expanded. But when I do that (hide and show
    the panel), the properties of the child controls are not persisted.

    Any hint on how I might do this?

    Thank you,
     
    Alexandre Soares, Jun 4, 2004
    #1
    1. Advertising

  2. Use ViewState.

    In a custom Server Control, this is absurdly easy to do. You create a
    Property, something like the following:

    public String PersistedProperty
    {
    get
    {
    if (ViewState["PersistedProperty"] == null) return "Default Value";
    return Convert.ToString(ViewState["PersistedProperty"]);
    }
    set
    {
    ViewState["PersistedProperty"] = value;
    }
    }

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "Alexandre Soares" <> wrote in message
    news:...
    > Hi,
    >
    > I've made a collapsible panel custom control. It's pretty simple so far,

    it
    > extends the Panel class and renders a bar above itself (panel) to

    show/hide
    > the <div> of the panel on the client-side using DHTML. So far it works

    fine.
    >
    > I want to be able to make it work server-side as well: only the topbar is
    > rendered if the panel is to be collapsed and the topbar AND the panel are
    > rendered if the panel is to be expanded. But when I do that (hide and show
    > the panel), the properties of the child controls are not persisted.
    >
    > Any hint on how I might do this?
    >
    > Thank you,
    >
    >
     
    Kevin Spencer, Jun 4, 2004
    #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. Assaf

    Persisting dynamic controls

    Assaf, May 19, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    465
  2. Jeff Rodriguez
    Replies:
    23
    Views:
    1,210
    David Schwartz
    Dec 9, 2003
  3. Replies:
    0
    Views:
    220
  4. xb

    Persisting Custom Control's Child tag's values

    xb, May 21, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    152
  5. Donal McWeeney

    Mixing child properties and child controls - how?

    Donal McWeeney, Feb 10, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    135
    [MSFT]
    Feb 14, 2005
Loading...

Share This Page