Reputation: 9621
I have a user control with this OutputCache:
<%@ OutputCache Duration="86400" VaryByControl="LnkBtnTopVanzari" %>
Where VaryByControl is the id of a link button i use to switch the active view of a multiView contained in an updatePanel.
The problem is that when i press that link button, the page does a full post back and the view is not switched.
If i remove the outputCache directive, all works great (pressing the link button the correct view is shown via ajax).
Do you know where i am wrong?
Thanks.
Upvotes: 2
Views: 355
Reputation: 3145
The VaryByControl parameter is used to vary depending on the value of the control which you specify. As the value of the link button will always be the same, the cache is not varied.
I believe this is intended to be used for controls such as dropdown lists, where it is feasible for the output to be different based on the selected value in the list.
You may want to try using VaryByParam and changing your link button to a hyperlink, specifying the view as a query parameter, or trying out VaryByCustom. Otherwise possibly you could possibly split the content of your views into separate user controls which are themselves output cached, leaving the multiview and your link button outside any caching.
Upvotes: 1