Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET MVC > General Discussions > ScriptRegistrar & Partial Views with Telerik Controls

Not answered ScriptRegistrar & Partial Views with Telerik Controls

Feed from this thread
  • Tim avatar

    Posted on Feb 2, 2012 (permalink)

    I seem to be having a problem where the ScriptRegistrar does not render all needed js files for the included Telerik controls when there is a Telerik control in a partial view...

    Using MVC3 Intranet Template and Razor syntax; added Telerik via NuGet.  (Sample project attached)
    • Layout contains stylesheet registrar and scriptregistrar statements and includes the menu control.

    • When the View (MenuOnly) has no other telerik controls, the menu renders fine.
    • When the View (ALL) has a telerik control (currency textbox in this case) and includes a parital control containing another telerik control (grid in this case), the menu renders fine.
    • When the View (MenuGrid) has only the partial control containing another telerik control (grid in this case), the script registrar fails to render the menu js files causing the menu not to operate correctly (i.e. rollovers and sub-menus when present)...

    My app really need the MenuGrid scenario whereby the partial view is refreshed via AJAX...  Is this a bug in the scriptregistrar?  Is there any workaround other than adding some other telerik control to the view as in the ALL case?

    -tim

    Reply

  • Tim avatar

    Posted on Mar 18, 2012 (permalink)

    Hello,

    I'm getting what appears to be the same behaviour (only in my case it's an AutoComplete element that isn't working). To make things easier (or perhaps more complicated), my name is also Tim. :)

    My setup is:
    1. Default MVC3 Internet Application in Visual Studio 2010
    2. Telerik MVC Extensions installed via NuGet Package Manager
    3. ScriptRegistrar located in _Layout.cshtml at bottom of <body>

    The behaviour is:
    1. AutoComplete element in view: ScriptRegistrar renders javascript file references and element works correctly
    2. AutoComplete element in partial view: ScriptRegistrar does NOT render references. Element doesn't work.
    3. AutoComplete element in view and AutoComplete in partial view: ScriptRegistrar renders javascript file references and both elements work correctly

    I've attached the example VS2010 solution which demonstrates these three cases.

    Does anyone have any idea what's going on here?

    Tim (2)

    Reply

  • Tim avatar

    Posted on Mar 18, 2012 (permalink)

    Hello again,

    I think I've found a potential solution.

    Both mine and Tim(1)'s solutions render the ScriptRegistrar in _Layout.cshtml like so:

    @{
        Html.Telerik().ScriptRegistrar()
                  ...
                       .Render();
    }

    However, if one removes the code block and the call to Render() like below, the problem is fixed. The javascript references are rendered (even when the element is only in the partial view) and the control works as expected. This is true for both my example solution and Tim(1)'s:

    @Html.Telerik().ScriptRegistrar()

    I have no idea why the code-block-and-render way doesn't work but this way does. Practically I guess the disadvantage to the this way is that you can't split the code over several lines to make it more readable.

    Tim(2)




    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET MVC > General Discussions > ScriptRegistrar & Partial Views with Telerik Controls