This is a migrated thread and some comments may be shown as answers.

$find no longer working after .NET 4.0 upgrade

3 Answers 92 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Paul Robertson
Top achievements
Rank 1
Paul Robertson asked on 23 Jan 2013, 02:04 PM
Hello all

Please forgive if this is the incorrect forum for such a query, but I have an inkling that this problem reflects a change in the way Telerik.Web.UI works with System.Web.Extensions, from the .NET 2.0-3.5 versions compared with the .NET 4.0 versions.

I have a site being upgraded to .NET 4.0, using Telerik.Web.UI Q3 2012 - the issue is that $find no longer works, it always returns null, when it features in my client-side Javascript. This issue did not arise in .NET 2.0 versions, so I believe it is a consequence of the upgrade to .NET 4.0 versions of Telerik.Web.UI.dll and the underlying MicrosoftAjax.js from within System.Web.Extensions.dll.

The code in question runs as a consequence of the $.ready function of jQuery 1.9, but as I need to emphasise, the issue was not previously evident with the.NET 2.0 versions of the dlls in question.

The exact symptom can be traced by debugging in Firefox with Firebug, where the call to $find can be seen to enter the MicrosoftAjax.js script file, but then immediately quit from the file evidently without running the $find function within the file.

I am not sure if this is the expected behaviour, as I have never encountered a problem with $find before. Am I right in understanding that there is a Telerik wrapper for $find in Telerik.Web.UI, that uses the version in MicrosoftAjax.js? In other words, is this likely to be a problem with the way that the MicrosoftAjax.js function is called, and is this call being made from the Telerik.Web.UI script resources? I am using the radScriptManager to control these WebResource.axd script resources.

I am not sure how to troubleshoot this problem, because the general explanations for looking into it are based around the issue of the function being called before the DOM is ready - however, in this case I am not sure this assumption is applicable, as the function used to work before in .NET 2.0, and also the fact that the $find function in MicrosoftAjax.js does not appear to run, and therefore does not get a chance to look for the DOM element in question.

If anybody could give me a pointer about a good way to proceed, I would be really grateful.

Thanks.

3 Answers, 1 is accepted

Sort by
0
Paul Robertson
Top achievements
Rank 1
answered on 23 Jan 2013, 03:38 PM
Some slight progress with this issue:

The reason firebug quits out from MicrosoftAjax.js appears to be related to the use of the EnableScriptCombine="true" property on the RadScriptManager, which loses the debugging symbols for the script in question. Setting EnableScriptCombine="false" allows Firebug to traverse through MicrosoftAjax.js, which reveals that the $find function (i.e. Sys.Application.findComponent) IS running, but when it examines the contents of the Sys.Application._components object, using the 'id' provided as the parameter, the _components object is empty, hence the function cannot look up the component with an index matching the id provided.

This suggests to me that the Telerik components are no longer being registered within Sys.Application._components in the same way as for the .NET 2.0 version of the controls.

Could anybody clarify whether such a change has taken place, and whether a manual registration is now required. If there is any relevant information about the recommended stage in the client-side life cycle for carrying out the registration and/or $find query for Telerik components, that would be enormously useful.

Regards
0
Paul Robertson
Top achievements
Rank 1
answered on 23 Jan 2013, 05:18 PM
Also:
I thought it might be something to do with the LoadScriptsBeforeUI property of the RadScriptManager, from the base ScriptManager class, as this property seems to be have been introduced since the original .NET 2.0 implementation, but unfortunately changing it from the default "true" to "false" does not seem to make any difference to the problem.

 
0
Dimitar Terziev
Telerik team
answered on 28 Jan 2013, 03:03 PM
Hello Paul,

If the $find statement returns null when called in the $.ready event handler, it is possible that the client-side object of the control that you want to obtain reference to is not yet initialized. In order to be sure that the client-side objects are already initialized, you could use the Sys.Application.load event and  find a reference to the desired control in its event handler function.

Greetings,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Ajax
Asked by
Paul Robertson
Top achievements
Rank 1
Answers by
Paul Robertson
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Share this question
or