Maintaining viewstate in Collections

  • Thread starter Patrick Wilby via .NET 247
  • Start date
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
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top