views:

488

answers:

1

I am currently working on an advanced web application that contains a number of Dynamically Rendered pages. The pages are standard pages which contain a place holder into which the main content is rendered from a combination of Xml and Xslt.

I have recently been attempting to add a ASP.Net Ajax Toolkit collapsible entender to allow the collapsing and extending of the panels which are dynamically rendered. I have added the extender markup to our main xslt template and all is fine. Well all is fine until a post back takes place and the panels return to their intial state. So, for example, if I load the page with the panels collapsed then after postback the page fails to reset any open panels, The problem is caused by the fact that I store the dynamic content in the viewstate itself and once the page is loaded just retrieve it from the viewstate rather than re-render the Xml.

Phew.... there is the background to the problem.

Now the main question. How on earth can you interact with the extender in Javascript. I have spent days convinced that I could cache the state in a page variable client side and then reapply the state post postback. However, there appears to be no documentation or knowledge of how to accomplish this. The best I have found is some very simple javascript which will allow you to register a couple of events to catch when the panel is extended or collapsed.

All I want to do is interact and cache each panels state. Can anyone suggest anything?

A: 

OK, Just in case anyone else needs to achieve similar I have now got it working.

After much research I found that you can hook up to a some client side events using either method described here.

So I decided the best way was to programtically add a couple of hidden fields (ASP.Net HiddenField) to the page in the Page_Load() event and add the names of each extender as a delimited string in one field and then have a field per extender to hold the extenders state. Once the page is posting back the value of each extenders hidden field is retrieved from the Request.Form object (the key of which is hidden fields ID) otherwise if it is the initial load just handle a default value.

Then I just created a simple client side script which handled the onExpand and onCollapse events and update the value of the specific extenders hidden field.

In the pageLoad event of the client script I just set the entenders state based on it's hidden fields value.

Simple really.... should have thought of it like that to start with!

The Great Gonzo