Here's an example of how I've been trying to do it, maybe it will work for you. Unfortunately, although it compiles and seems to run it doesn't actually seem to work for me. In my case I'm trying to force the category to expand when a user clicks a command button to add an item to the category.
My CollapsiblePanelExtender is defined in the ASP page like this:
<ajaxToolkit:CollapsiblePanelExtender ID="cpeCategory" runat="server" TargetControlID="CategoryContentPanel"
Collapsed="true" ExpandControlID="CategoryToggleImage" CollapseControlID="CategoryToggleImage"
ExpandDirection="Vertical" ImageControlID="CategoryToggleImage" ExpandedImage="~/images/expand.gif"
CollapsedImage="~/images/collapse.gif" SuppressPostBack="true" />
And my code-behind (triggered on a LinkButton) is defined like this:
protected void Category_Command(object sender, FormViewCommandEventArgs e)
{
if (e.CommandName == "AddItem")
{
cpeCategory.Collapsed = false;
cpeCategory.ClientState = false.ToString().ToLower();
//Other processing here..
}
}
I've tried playing around with doing the ClientState set before, after, and both before and after setting the Collapsed property and it didn't make an impact. I've also tried doing this via javascript but haven't had much success that direction since I'm not very familiar with it.
Hopefully this code-example answers your question, and hopefully somebody else can point out what I'm doing wrong?