2

I'm writing a DropDownList adapter in order to add 2 pieces of functionality to the built in DropDownLists, using a combination of the following solutions:

  1. OptionGroup Support
  2. Persistence of custom attributes across postback

This works fine if the DropDownList items are declared in markup. However, when items are added dynamically I'm relying on the items being restored from ViewState.

The problem is that ControlAdapter.LoadAdapterViewState gets called BEFORE Control.LoadViewState, therefore I cannot reapply my OptionGroup/Custom attributes to the Items as they don't exist yet.

So firstly, what is the reasoning behind this order of events?

And secondly, where else in the life cycle can I safely set these custom attributes back onto the items? Note: PreRender can't be used as the ViewState gets lost if the control is not going to be rendered on the page (e.g. in a wizard).

Community
  • 1
  • 1
Brett Postin
  • 11,215
  • 10
  • 60
  • 95

0 Answers0