P
Patrick Wilby via .NET 247
--------------------------------
From: Patrick Wilby
Hi
I have a custom control inherited from Control that has a coupleof simple string properties and a property which is based onCollectionBase which holds objects of type TabPage(againinherited from Control). The TabPage control has a stringproperty called Caption. Internally the TabPage objects maintainthe state of Caption via viewstate. If I place a TabPage objectonto a web page and change its Caption property (in effectmimicing a textbox) and postback it maintains its state. NoProblem. However, when I place TabPage objects into theCollectionBase collection, and postback I cannot maintain thestate of the Caption property. I have searched every where tofind an answer to this but to no avail. Somehow the collectionproperty needs to persist the state of its items to viewstatei.e. the Caption property of each TabPage object. I've looked atthe IStateManager interface which looks as though this might bethe answer but I am unsure as to where to implement this or how:should it be at the top level i.e. in the Custom contol class orin the Collection class or both? I used the IPostBackDataHandlerinterface in the TabPage class to pick up any changes in statefor that class. Do I need to do the same for this problem? Anyvery simple (its my first custom control)example/strategieswould be most appreciated (VB) preferably.
Thanks
Patrick
From: Patrick Wilby
Hi
I have a custom control inherited from Control that has a coupleof simple string properties and a property which is based onCollectionBase which holds objects of type TabPage(againinherited from Control). The TabPage control has a stringproperty called Caption. Internally the TabPage objects maintainthe state of Caption via viewstate. If I place a TabPage objectonto a web page and change its Caption property (in effectmimicing a textbox) and postback it maintains its state. NoProblem. However, when I place TabPage objects into theCollectionBase collection, and postback I cannot maintain thestate of the Caption property. I have searched every where tofind an answer to this but to no avail. Somehow the collectionproperty needs to persist the state of its items to viewstatei.e. the Caption property of each TabPage object. I've looked atthe IStateManager interface which looks as though this might bethe answer but I am unsure as to where to implement this or how:should it be at the top level i.e. in the Custom contol class orin the Collection class or both? I used the IPostBackDataHandlerinterface in the TabPage class to pick up any changes in statefor that class. Do I need to do the same for this problem? Anyvery simple (its my first custom control)example/strategieswould be most appreciated (VB) preferably.
Thanks
Patrick