views:

43

answers:

1

I have a sitecore page with an ASP dropdownlist, and the data on the form is populated from the selected value of the dropdown. When the selected item of the dropdownlist is changed, a postback is fired. In the postback, the new selected item is added to the querystring and the user is redirected (for linkability).

I recently enabled HTML caching (for all sublayouts, "Vary by querystring"), and now suddenly, this mechanism no longer works. What seems to happen is I select a new dropdown item, the page appears to post back (though if I'm debugging, none of my breakpoints get hit). After that, if I change the selected item again, I can see in Firebug the message "__doPostBack is not defined", which appears to mean the ASP-generated JavaScript is not being added to the page.

+1  A: 

Enabling caching for a sublayout means you are bypassing the code entirely and Sitecore is just serving up the same HTML it generated previously. So it's behaving as designed. In other words, this does not seem to be a scenario where you can take advantage of sublayout caching.

Bryan
So does that mean you can never use sublayout caching where you postback?
Ed Schwehm
See http://intothecore.cassidy.dk/2008/07/say-goodbye-to-sitecore-53.html and http://intothecore.cassidy.dk/2008/07/return-to-not-so-cacheable-control-in.html. Both are specific for version 5.3, but I have a feeling Sitecore's position is - this faulty behaviour is "by design". There are a few ways to work with it however.
Mark Cassidy
This answer is correct. Working as designed. You might be able to cache other fragments of the page, or if performance is still an issue, refactor to use jQuery+JSON AJAX instead of a postback.
techphoria414