Hi everyone
I'm fighting with this issue for quite a long time now, and so I thought this would be the right place to ask a question regarding this little issue.
Every time I try to cache data with the System.Web.Caching.Cache property, I get the 'Controls cannot be ajaxified after Page PreRender.'-error at the line where I call AddAjaxSettings on the RadAjaxManager. When I remove the caching lines, everything just works fine. I sincerely do not know why the usage of the Cache property causes the AjaxManager to throw an exception.
The following describes the faulty scenario:
I have a RadTreeView in the Master page. When a node of it is dropped, some data I want to cache is loaded into a RadGrid which is placed in the Default.aspx page. After this step the thing crashes (the first time - the data is not in the cache yet - it loads the data into the grid; the second time - data is in the cache now - it throws the abovementioned exception). The caching code is actually very simple:
BindingList<string> strings = Cache["LotsOfItems"] as BindingList<string>; |
if (strings == null) |
{ |
strings = MyClass.GetLotsOfStrings(); |
Cache.Insert("LotsOfItems", strings, null, DateTime.Now.AddMinutes(1), Cache.NoSlidingExpiration); |
} |
myGrid.DataSource = strings; |
myGrid.DataBind(); |
I hope somebody can help me out with this one. I'll provide further information if needed.
Thanks very much.
Kind regards,
Mallory