[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

Proper way to reload CompositeControl when its state must change after Postback

jeljeljel

9/19/2007 10:41:00 PM

I am creating a CompositeControl that contains a Table. The rows in
the Table are controlled by an internal pager. The control renders
the pager and the table. When the user clicks the pager, the control
shows the next set of records in the table.

Assume after the OnLoad method the control has regenerated to the
exact state when the last time the page unloaded (with ViewState or
some other means -- important part is the control's state is the same
as when the page unloaded). Then the control changed events fire,
then the post back events fire. A post back event is received from
the Pager that the user requested a new page.

So now the CompositeControl must "tear down" the old markup and
regenerate the new markup.

Is this as simple as calling Controls.Clear()? There must be more to
it, b/c when I call Controls.Clear(), the Count becomes 0, and I
create the new markup (in CreateChildControls). The Count property on
Controls.Count shows new controls have been added, but when the page
renders, the original markup is what displays.

Thanks,
John

1 Answer

Teemu Keiski

9/20/2007 7:37:00 PM

0

Hi,

do you mean

1. call Controls.Clear()
2. Set ChildControlsCreated flag to false
3. call EnsureChildControls()

Note: putting call of Controls.Clear() as first line in CreateChildControls
removes the first step.

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice....
http://teemu...


"jeljeljel" <livermore.john@gmail.com> wrote in message
news:1190241634.789901.36260@o80g2000hse.googlegroups.com...
>I am creating a CompositeControl that contains a Table. The rows in
> the Table are controlled by an internal pager. The control renders
> the pager and the table. When the user clicks the pager, the control
> shows the next set of records in the table.
>
> Assume after the OnLoad method the control has regenerated to the
> exact state when the last time the page unloaded (with ViewState or
> some other means -- important part is the control's state is the same
> as when the page unloaded). Then the control changed events fire,
> then the post back events fire. A post back event is received from
> the Pager that the user requested a new page.
>
> So now the CompositeControl must "tear down" the old markup and
> regenerate the new markup.
>
> Is this as simple as calling Controls.Clear()? There must be more to
> it, b/c when I call Controls.Clear(), the Count becomes 0, and I
> create the new markup (in CreateChildControls). The Count property on
> Controls.Count shows new controls have been added, but when the page
> renders, the original markup is what displays.
>
> Thanks,
> John
>