Reputation: 2359
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?
Upvotes: 0
Views: 4774
Reputation: 555
I've run into this in another circumstance...
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().
Upvotes: 0
Reputation: 657
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
Upvotes: 3