www.codinghillbilly.com   kyle.baley.org  Subscribe / Contact
 
 
 
 
LATEST POSTS
Wednesday, September 19, 2007

Today's post brought to you by honorary Hillbilly, Kevin Hemeon, who sent the following e-mail:

Dear Coding,

I realize you're a big mucky-muck who is too busy for the likes of the little people but my job, my life, indeed my very *soul* depends on being able to collapse an ASP.NET AJAX Toolkit CollapsiblePanel programmatically in a postback event, such as a button click. I've tried using myCollapsiblePanel.Collapsed = true but it doesn't work.

And I, being a blogger mindful of his readership, replied:

Kind and noble Kevin,

The solution to this problem is mere child's play and it certainly did *not* take me a good couple of hours wondering "WTF" while I stared in disbelief at what should be an obvious piece of code. You see, the CollapsiblePanel is "postback-aware" in that it will save its state during a postback and re-create it. This is very handy when you are submitting a form and you don't want to startle people who are easily offended by things such as UI elements that look different when a web page refreshes. That's the sort of behaviour that tends to lead to warnings on coffee cups, if you catch my meaning.

Unfortunately, this doesn't bode well if, in the postback, you want to alter its appearance manually. In this case, another line of code is necessary:

   myCollapsiblePanel.ClientState = "true";
   myCollapsiblePanel.Collapsed = true;

So you see, a simple solution for a simple problem (i.e. not a problem that appears simple but keeps you up all &*%$ night). Until next time, code strong and AJAX well.

Kyle the (De)Mentor

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Copyright © 2010 Kyle Baley. All rights reserved.
 
CATEGORIES
.NET General (18) alt.net (4) altnetconf (9) ASP.NET AJAX (40) ASP.NET MVC (29) Bahamas (1) Bahanet (9) BDD (1) Brownfield (18) Career (9) Castle (1) Code coverage (1) Coding Style (6) Communication (1) Community (18) Conscientious Coding (34) Continuous Integration (11) dasBlog (12) Development (16) DevTeach (4) Domain (2) Environment (4) Estimating (1) Featured (14) Flamingo (10) Games (1) Google App Engine (2) GWT (5) Hardware (6) Java (1) Javascript (7) Linq (2) Livelink (6) Lucene.NET (2) MbUnit (1) Metrics (1) Miscellaneous (24) Mocking (4) NAnt (4) NHibernate (12) NInject (1) Office (3) Office Development (6) Open Rasta (1) Patterns (5) Presenting (13) Professional Development (15) Refactoring (10) ReSharper (11) REST (2) S#arp Architecture (5) Security (3) Software (11) Sundry (18) TDD (19) Tools (21) User Interface (5) Utilities (8) Visual Studio (8) VSTO (1) Web development (12) Windows (3) Working Remotely (16) Workplace (3) Writing (4)
 
LATEST POSTS
 
POPULAR POSTS
 
 
ARCHIVE