update of custom control

Discussion in 'ASP .Net Building Controls' started by John Bankhead, Dec 21, 2004.

  1. I created a user control that displays different subsets of data depending on
    the value of its public property "Folder". I placed the control on my page
    along with four asp:buttons to represent the four different folders. The
    clicking a button fires off the folder_click function which in turn sets the
    Folder property on the user control.

    The situation that I had was that I would not see the folder change until
    there were two round-trips to the server. The data that shown was always one
    click behind.

    To fix this, I placed the line: this.ChildControlsCreated = false; in the
    set section of the Folder property. And it worked.

    So my question is: Is this what I should have done? Or is it just a patch?


    --
    John Bankhead
    John Bankhead, Dec 21, 2004
    #1
    1. Advertising

  2. Hi John,

    What you're doing seems ok. If what you're developing is a composite custom
    control and you perform some action (i.e. in response of a click event) that
    will alter its child controls tree then you need to set ChildControlsCreated
    to false in order to invalidate the current child controls tree; ASP.NET
    will take care of recreating them when needed (i.e. just before rendering)
    by calling CreateChildControls again.

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    My blog: http://clariusconsulting.net/vga
    My profile: http://aspnet2.com/mvp.ashx?vga

    "John Bankhead" <> wrote in message
    news:...
    >I created a user control that displays different subsets of data depending
    >on
    > the value of its public property "Folder". I placed the control on my
    > page
    > along with four asp:buttons to represent the four different folders. The
    > clicking a button fires off the folder_click function which in turn sets
    > the
    > Folder property on the user control.
    >
    > The situation that I had was that I would not see the folder change until
    > there were two round-trips to the server. The data that shown was always
    > one
    > click behind.
    >
    > To fix this, I placed the line: this.ChildControlsCreated = false; in the
    > set section of the Folder property. And it worked.
    >
    > So my question is: Is this what I should have done? Or is it just a
    > patch?
    >
    >
    > --
    > John Bankhead
    Victor Garcia Aprea [MVP], Dec 23, 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. Jonah Olsson
    Replies:
    1
    Views:
    560
    Scott Allen
    Apr 5, 2005
  2. J R M
    Replies:
    2
    Views:
    412
    Charlie@CBFC
    Jun 1, 2006
  3. Matt Sokol
    Replies:
    2
    Views:
    358
    Theo Tillotson
    Aug 7, 2003
  4. Terry Holland
    Replies:
    9
    Views:
    198
    Steven Cheng[MSFT]
    Oct 28, 2005
  5. Pete Mahoney

    ASP.Net Server Control (Web Custom Control) Code Update Problem

    Pete Mahoney, Sep 1, 2004, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    173
Loading...

Share This Page