Posts Tagged ‘BaseFieldControl Caching’

Caching in the SharePoint BaseFieldControl

August 5th, 2009 Comments off

This is definitely a new thing for me Today. We had some issue in a page title control on a SharePoint site. This is a simple SharePoint BaseFieldControl, we are using to display the page title on different pages. This control is relying on query string values. The issue I was looking for is ‘Page title is not changing on different pages for different query string values’.

When I have started debugging this control, I have noticed that it is ignoring query string value sometimes. Seems some caching is on. But there was no caching on from the developer. After some playing around I reached to the problem. BaseFieldControl by default do caching for displaying html, and for this it has a property name ‘CanCacheRenderedFieldValue’. The default value for CanCacheRenderedFieldValue is true.  

To resolve it I simply override the OnInit method and set the value for CanCacheRenderedFieldValue to false. It sorted out the ambiguous problem.

Hope you have enjoyed it.