New to Telerik UI for ASP.NET Core? Download free 30-day trial

Razor Page

MultiSelect Remote Data Binding in Razor Pages

This article describes how to configure a Remote DataSource of a Telerik MultiSelect in a RazorPage scenario.

In order to set up the MultiSelect component bindings, you need to configure the Read method of its DataSource instance. The URL in this method should refer the name of the method in the PageModel. In this method, you can also pass additional parameters, such as filter string and antiforgery token (see dataFunction). See the implementation details in the example below, and for the full project with RazorPages examples, visit our GitHub repository.

    @inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
    @Html.AntiForgeryToken()

    <h1>MultiSelect Index</h1>

    @(Html.Kendo().MultiSelect()
        .Name("customers")
        .DataTextField("Name")
        .DataValueField("CustomerId")
        .Filter(FilterType.Contains)
        .ItemTemplate("<span>  #: data.CustomerId # </span> <h4> #: data.Name # <h4>")
        .DataSource(ds => ds
            .Custom()
            .Transport(transport => transport
                .Read(r => r
                    .Url("/MultiSelect/MultiSelectIndex?handler=Read").Data("forgeryToken")
                ))
                .ServerFiltering(false)
            )
        )

    <script>
        function forgeryToken() {
            return kendo.antiForgeryTokens();
        }
    </script>

        public JsonResult OnGetRead(string filterValue)
        {
            var data = customers;
            return new JsonResult(data);
        }

See Also

In this article
Not finding the help you need? Improve this article