Stephen2

SitefinityUserControl example

Feb 22nd, 2014
1,490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. protected override CacheLevel ControlCacheLevel {
  2.     get {
  3.         return CacheLevel.ContentListener;
  4.     }
  5. }
  6.  
  7. protected override List<CacheDependencyKey> GetCacheDependencyObjects() {
  8.     var cacheDependencyObjects = new List<CacheDependencyKey>();
  9.            
  10.     //Example listening to any PageNode event - e.g., a Navigation control
  11.     cacheDependencyObjects.Add(new CacheDependencyKey() {
  12.         Type = typeof(PageNode),
  13.         Key = null
  14.     });
  15.  
  16.     //Example listening to any NewsItem event - e.g., a News List type control
  17.     cacheDependencyObjects.Add(new CacheDependencyKey() {
  18.         Type = typeof(NewsItem),
  19.         Key = null
  20.     });
  21.  
  22.     //Example listening to a single Image Item - e.g., a banner control or similar...
  23.     //NOTE: in a real example, you would use a public Guid as the key, and use that same Guid to get/display the image
  24.     //    : The .ToUpperInvariant() is important
  25.     cacheDependencyObjects.Add(new CacheDependencyKey() {
  26.         Type = typeof(Telerik.Sitefinity.Libraries.Model.Image),
  27.         Key = "A72D2064-DB9A-6D2B-9FAD-FF0000A141DD".ToUpperInvariant()
  28.     });
  29.  
  30.     //If this is a Control that has Comments available, you'll want to listen to all Comment events
  31.     //That way, when a new one is added, the page this control lives on will automatically invalidate
  32.     cacheDependencyObjects.Add(new CacheDependencyKey() {
  33.         Type = typeof(Comment),
  34.         Key = null
  35.     });
  36.  
  37.     return cacheDependencyObjects;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment