Error: "'Telerik' is undefined" when using OutputCache directive in a user control
|
Article relates to
|
RadControls for ASP.NET AJAX
|
|
Created by
|
Rumen, Telerik
|
|
Last modified
|
2010/01/13
|
|
Last modified by
|
Rumen, Telerik
|
PROBLEM
Error: "'Telerik' is undefined" when using OutputCache directive in a user control
DESCRIPTION
In ASP.NET AJAX enabled web sites, you can receive the "'Telerik' is undefined" js error after the first page PostBack of the page. The problem does not appear when the page is loaded for the first time, but only after the subsequent page postbacks. The problem is caused by the OutputCache page directive:
<%@ OutputCache Duration="3600" VaryByParam="none" %>
When using the above directive, the HTML string that is sent from the server to the client is cached. After a postback, the code for the Control is not executed but rather the string that is sent to the client is taken from the cache. However, the Telerik controls need to register all necessary js files in the HEAD of the page, which in turn is not cached. Thus, after you click a button or another element that causes PostBack, merely an HTML string is sent to the client for the control, the js files are not registered and as a result, you will receive "'Telerik' is undefined".
SOLUTION
To fix the problem set the RegisterWithScriptManager property of the Telerik control to False. This will tell the control to be separate from the script manager and it will register its scripts itself.
Please note that the Telerik control should be static and it should not use its AJAX features and make Ajax requests when it is cached.
For example: The RadTreeview control should not load its notes using Load-On-Demand.
Comments
If you'd like to comment on this KB
article, please, send us a
Support Ticket.
Thank you!
Please
Sign In
to rate this article.