update of custom control

J

John Bankhead

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?
 
V

Victor Garcia Aprea [MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top