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

RegisterClientScriptResource doesn't work with control used in RadAjaxManager

5 Answers 159 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
JP
Top achievements
Rank 1
JP asked on 15 Dec 2011, 05:26 PM
Hello,

my control is updated by a RadAjaxManager which works fine. But now I try to register a client script resource. I don't get an exception when doing this, but the webresource isn't rendered into the page. The path to the embedded resource must be correct because using a wrong path generated an exception.

This is what I do in OnPreRender:
ScriptManager.RegisterClientScriptResource(this, GetType(), "Search.MySearch.js");

This is what I added to AssemblyInfo.cs:
[assembly: WebResource("Search.MySearch.js", "text/javascript")]

When I look into the assembly with dotPeek, I can see that the resource name is correct. Why doesn't 
the javascript file get rendered into the page? I don't use the RadScriptManager at the moment.

If I don't add the specific AjaxSetting to the RadAjaxManager, the script resource is added to the page.

Thanks for your help!

5 Answers, 1 is accepted

Sort by
0
Accepted
Antonio Stoilkov
Telerik team
answered on 20 Dec 2011, 09:44 AM
Hello Jan-Patrick,

You could try calling the RegisterClientScriptResource as it is shown below. Note that the second parameter is used by .NET to find the assembly containing the resource, so it is possible this is the reason for the issue.
ScriptManager.RegisterClientScriptResource(Page, typeof(MyBaseCustomControl), "Search.MySearch.js");

Greetings,
Antonio Stoilkov
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
0
Jorge
Top achievements
Rank 1
answered on 21 Dec 2011, 08:51 PM
The solution described don't work here. Still not including the script on the page.
0
Antonio Stoilkov
Telerik team
answered on 27 Dec 2011, 09:38 AM
Hi Jorge,

In order to further investigate the issue you could open a formal ticket and send us a sample project demonstrating the unwanted behavior.

Greetings,
Antonio Stoilkov
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
0
JP
Top achievements
Rank 1
answered on 02 Jan 2012, 12:35 PM
The solution worked for me.
Jorge, did you also include the script using the WebResource and ScriptResource attribute?

[assembly: WebResource("Search.MySearch.js", "text/javascript")]
[assembly: ScriptResource("Search.MySearch.js")]
0
Jorge
Top achievements
Rank 1
answered on 02 Jan 2012, 05:01 PM
Thanks, JP.

I have included only the WebResource definition. I will now include the ScriptResource definition and to test.
Tags
Ajax
Asked by
JP
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Jorge
Top achievements
Rank 1
JP
Top achievements
Rank 1
Share this question
or