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

[Solved] Html.Telerik().ScriptRegistrar() and Conditional Control Loading Issue

1 Answer 100 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Hardy Wang
Top achievements
Rank 1
Hardy Wang asked on 14 Mar 2011, 03:30 AM
Hi all,

I added <% Html.Telerik().ScriptRegistrar().Render(); %> to the end of my master page as requested by Telerik document.

I have a page to use the master page, inside the page a partial view is embedded, and inside the partial view I have some condition to determine a Grid control to show or not.

Some code samples are:

From view I have <% Html.RenderPartial("MyPartialView", new MyViewModel()); %>

From MyPartialView.ascx I have:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MyViewModel>" %>
<%
    if (Model.SomeValue == true) {
%>
<% Html.Telerik().Grid(Model.Lists)
                .Name("Lists")
                .Columns(columns =>
                {
                    columns.Bound(g => g.Name).Title("Name");
                })
                .Footer(false)
                .Resizable(resizing => resizing.Columns(true))
                .Render();
            %>
<%
    }
%>

When I run the page, I could not see Telerik().ScriptRegistrar() will render <script type="text/javascript" src="/Scripts/2010.3.1318/telerik.grid.min.js"></script> in my Html page. Thus some of my client side function could not be performed.

Any idea what shall I do in this situation?

Thanks
Hardy

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 14 Mar 2011, 07:33 AM
Hi Hardy,

Javascript files that will be used by a component in a partial view, should be registered explicitly.

http://www.telerik.com/help/aspnet-mvc/using-with-partial-views-loaded-via-ajax.html

http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-troubleshooting.html#LoadOnDemand


All the best,
Dimo
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
General Discussions
Asked by
Hardy Wang
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or