Sunday, March 11, 2012

CollapsiblePanelExtender, programatically collapse a panel

Hi joee,

You should check outFAQ Item #19.

Thanks,
Ted

The FAQ says to do this:

CollapsiblePanelProperties properties = cpe.GetTargetProperties(Panel1);
if (properties != null)
{
properties.ClientState = collapsed.ToString().ToLower();
properties.Collapsed = collapsed;
}

However, unless I'm missing something, cpe does not have the methods GetTargetProperties (did this change recently?). I'm trying this:

cpe.Collapsed = true;
cpe.ClientState = "true";

Which is syntactically valid, but nothing happens after the postback. Is there something on the client side that you're supposed to do?


Yes, the FAQ entry is a bit out of date. Your translation seems valid - make sure you're using the 61121 release since we fixed something related there.

I can confirm that this does *not* work:

cpe.Collapsed = true;

Code gets executed but the panel does not collapse. I'm usingversion 1.0.61121.0.

Cheers,

-Benton


Note that there are two steps above, not just one. Also, please refer to the ToolkitTests\Manul\ClientStateLifecycle.aspx page for an example of this in action.
Thanks David. Yes, I was running a slightly older copy (1.0.61106.0). I pulled down 61121, dropped in the new dll and it seems to be working fine with the syntax I mentioned above. I guess with this kind of stuff I have to check more often than every month or two for updates :)

No comments:

Post a Comment