RegisterClientScriptResource doesn't work with control used in RadAjaxManager

6 posts, 1 answers
  1. JP
    JP avatar
    122 posts
    Member since:
    Aug 2011

    Posted 15 Dec 2011 Link to this post

    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!
  2. Answer
    Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 20 Dec 2011 Link to this post

    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
  3. Jorge
    Jorge avatar
    4 posts
    Member since:
    Feb 2011

    Posted 21 Dec 2011 Link to this post

    The solution described don't work here. Still not including the script on the page.
  4. Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 27 Dec 2011 Link to this post

    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
  5. JP
    JP avatar
    122 posts
    Member since:
    Aug 2011

    Posted 02 Jan 2012 Link to this post

    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")]
  6. Jorge
    Jorge avatar
    4 posts
    Member since:
    Feb 2011

    Posted 02 Jan 2012 Link to this post

    Thanks, JP.

    I have included only the WebResource definition. I will now include the ScriptResource definition and to test.
Back to Top