Edit this page

Hybrid View HtmlHelper Overview

The hybrid View HtmlHelper extension is a server-side wrapper for the hybrid Kendo UI View widget.

It allows you to configure the hybrid Kendo UI View from server-side code.

Configuration

Below are listed the steps for you to follow when configuring the hybrid Kendo UI View for ASP.NET MVC.

  1. Create a new ASP.NET MVC 4 application. If you have installed the Telerik UI for ASP.NET MVC Visual Studio Extensions, create a Telerik UI for ASP.NET MVC application. If you decide not to use the Telerik UI for ASP.NET MVC Visual Studio Extensions, follow the steps from the introductory article to add Telerik UI for ASP.NET MVC to the application.

  2. Open HomeController.cs and modify the Index action method.

    Example
        public ActionResult Index()
        {
            return View();
        }
    
  3. Add a Kendo UI View to the Index view.

    Example
    
            <% Html.Kendo().MobileView()
                    .Title("View Title")
                    .Content(() =>
                    {
                        %>
                            View Content Template
                        <%
                    })
                    .Render();
            %>
    
    
            @(Html.Kendo().MobileView()
                    .Title("View Title")
                    .Content(
                        @<text>
                            View Content Template
                        </text>
                    )
            )
    
  4. Initialize the mobile application.

    Example
    
            <%: Html.Kendo().MobileApplication()
                    .ServerNavigation(true)
            %>
    
    
            @(Html.Kendo().MobileApplication()
                .ServerNavigation(true)
            )
    
  5. Build and run the application.

Event Handling

You can subscribe to all hybrid View events.

By Handler Name

The following example demonstrates how to subscribe to events by a handler name.

Example

        <%: Html.Kendo().MobileView()
                .Name("MobileView")
                .Events(events => events
                    .AfterShow("onAfterShow")
                )
        %>

        <script>
        function onAfterShow() {
            //Handle the show event.
        }
        </script>

        @(Html.Kendo().MobileView()
                .Name("MobileView")
                .Events(events => events
                    .AfterShow("onAfterShow")
                )
        )

        <script>
        function onAfterShow() {
            //Handle the show event.
        }
        </script>

Reference

Instances

You can reference a hybrid View instance by using the jQuery.data() method and the value specified through the Name() method. Once a reference is established, use the hybrid View API to control its behavior.

Example
  @(Html.Kendo().MobileView()
          .Name("MobileView")
  )
  <script>
  $(function() {
      //Notice that the Name() of the View is used to get its client-side instance.
      var view = $("#Mobileview").data("kendoMobileView");
  });
  </script>

See Also