Question

I have a ajaxToolkit:CollapsiblePanelExtender along with two asp:UpdatePanels it controls (one panel expands the other panel when clicked).

Works great until I do an AJAX update from a Timer that kicks off. The page updates...and the CollapsiblePanelExtender collapses :-P

Anyone know how to get this control to maintain the state of the panel it's expanding?

Was it helpful?

Solution

I remember running into this exact problem.

CollapsiblePanelExtender has a property, ClientState, that doesn't seem to get tracked and maintained in ViewState.

You should be able to manually track and maintain the value in a HiddenField (or ViewState or Session, if you like) and restore the CPE.ClientState to that value upon the AJAX update.

UPDATE
Found a resource that suggests that you simply need to set both Collapsed and ClientState properties. http://weblogs.asp.net/ashicmahtab/archive/2008/11/21/act-collapsiblepanelextender-how-to-collapse-expand-programmatically.aspx

OTHER TIPS

I've run into this in another circumstance...

  1. Panel is collapsed Timer ticks, and a partial postback begins
  2. User expands panel while postback is in progress
  3. Partial postback ends, and the state of the panel is returned to "collapsed" because viewstate is maintained - it's just returned to where it was at the beginning of the partial postback.

How you want to handle this depends on your circumstance, but in my case I cancel the asynchronous postback when the user expands or collapses a panel. Since it's a timer updating current values every few seconds, it will just run again soon anyway so I'm able to "lose" one.

Alternately, you could disable expand/collapse functionality for the duration of the postback by using the panel's add_expanding and add_collapsing events, and checking Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top