ASPX templates
Version 5.x > ASPX templates > Caching is not working correctly when setting web part properties dynamically. View modes: 
User avatar
Certified Developer v6
Certified Developer v6
Nortech - 10/26/2011 6:29:06 AM
   
Caching is not working correctly when setting web part properties dynamically.
In the aspx template engine, we have cerated a template page that contains a webpart (cmsrepeater). We want to set the properties of that webpart either in the aspx's code behind or by using code blocks in the html of the aspx page.

In order to do this, we have used the method described in developer guide "Setting web part properties dynamically in your code". We have set the properties of the webpart in the oninit event of the aspx page and then called ReloadData() method of the webpart. This displays the correct data, but the caching mechanism ignores the properties set in the oninit event. The data stored in the cache are based on the default properties of the webpart.

What is the correct way to set webpart properties dynamically and keep the caching mechanism working correctly?

User avatar
Member
Member
kentico_michal - 11/8/2011 4:25:36 AM
   
RE:Caching is not working correctly when setting web part properties dynamically.
Hello,

You could try to flush all cached data manually: Deep dive: Cache dependencies

When you do not know what is the dummy key under which Repeater has cached the data you can specify it manually using the CacheItemName property.

Moreover, for aspx template it is recommended to use CMSRepeater control instead of Repeater web part.

Best regards,
Michal Legen