Setting a CollapsiblePanelExtender state from CodeBehind

Published 21 January 08 11:00 AM | Tom Wardill

Usefully, the CollapsiblePanelExtender has a property called "Collapsed", this can be set in the aspx to whatever you want the default state to be. However, if you just set this property from CodeBehind, you will find that it ignores you and doesn't do anything. This is because you also need to set the ClientState property to be the same as the Collapsed property (Except a string, rather than a bool).

Like so:

 CollapsiblePanel1.Collapsed = true;
 CollapsiblePanel1.ClientState = "true";

Filed under: , ,

Comments

# J said on February 21, 2008 09:11 PM:

I LOVE YOU! YOU SAVED MY DAY!

# ZeroCool said on March 5, 2008 09:44 AM:

But when I create and add multiple CollapsiblePanelExtender controls, it will always throw an exception says that there're multiple controls with the same ID '_ClientState', how to solve this problem? SOS!

Leave a Comment

(required) 
(required) 
(optional)
(required)