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

[Solved] Rendering scripts via ajax request

0 Answers 33 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.
Paul
Top achievements
Rank 1
Paul asked on 12 Feb 2011, 10:43 AM
I am using the script registrar in the master page and it correctly loads the scripts and the code to register the controls within the page.

My problem is when I load content via ajax. Since the master page doesn't know about the control when the page loads, the scripts and code for the control never gets loaded. That is to be expected. However, when the content gets loaded, I want it to content just the setup code for the control within the ajax request.

I tried adding the following within my ajax view.
@MvcHtmlString.Create(HttpUtility.HtmlDecode(Html.Telerik().ScriptRegistrar().ToHtmlString()))

@(Html.Telerik().Grid<Nop.Core.Domain.Catalog.ProductCategory>(Model.CurrentProducts)
        .Name("Grid")
        .DataKeys(keys => keys.Add(c => c.Id))
        .ToolBar(commands => commands.Insert().ImageHtmlAttributes(new { style =
            "margin-left:0" }))
        .DataBinding(dataBinding =>
        {
            dataBinding.Ajax()
                .Insert("List""Category")
                .Enabled(true);
        })
        .Columns(columns =>
        {
            columns.Bound(x => x.Id);
            columns.Bound(p => p.IsFeaturedProduct).Width(210);
        })
        .Editable(editing => editing.Mode(GridEditMode.InLine))
        .Pageable()
        .Sortable())

I expected the ScriptRegistrar load all the required scripts and setup code for the control, but it doesn't.

Solution?
Tags
General Discussions
Asked by
Paul
Top achievements
Rank 1
Share this question
or