Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CheckBoxList loosing state in custom container

2 views
Skip to first unread message

DZ-Jay

unread,
Oct 6, 2006, 12:43:15 PM10/6/06
to

Hello:
I created a custom container control, descendant of Control, that allows its contents to be "collapsed" (hidden) by exposing a button that changes the visilibity of a internal panel control.

This "collapsible" container implements INamingContainer and exposes a public ITemplate property, which will be instantiated in the internal panel control.

As far as I know, there is nothing strange about this container, it creates its children in CreateChildrenControls() and renders its output by overriding the Render() method.

The problem is that (for some reason) CheckBoxList and RadioButtonList controls do not keep the checked state of their items when declared within the collapsible control's template (in the aspx markup).

I created a CheckBoxList descendant and implemented the IPostBackDataHandler interface to see what's received and noticed a very curious thing: the LoadPostData() method was being called even when the control was "collapsed" (innerpanel.visible := false), and the CheckBoxList was not rendered at all!

This obviously is "posting" phantom data (which happens to be blank) when the CheckboxList is not on the page, and thus clearing the checked state of the items.

Does anybody know what would cause this behavior, or how could I begin to trace what's causing it?

Thank you very much.
-dZ.

DZ-Jay

unread,
Oct 6, 2006, 1:27:30 PM10/6/06
to

Hello:
I was able to solve this by just setting the inner panel's visibility to False the moment that it is created (in CreateChildControls()), before instantiating the template.

I'm not sure why this solves it, or why the problem occurred in the first place, but apparently instantiating the template on a "visible" panel guarantees that it will be processed during postback -- regardless of its actual (or eventual) visibility on the page.

Can anybody shed some light on this? I want to make sure I won't have any unintended consequences from this change.

Thank you,
-dZ.

0 new messages