Hybrid Layout HtmlHelper Overview

The hybrid Telerik UI Layout HtmlHelper for ASP.NET MVC is a server-side wrapper for the hybrid Kendo UI Layout widget.

Basic Configuration

  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.

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

        <% Html.Kendo().MobileLayout()
            .Name("layout") // The Layout `id`.
            .Platform("ios")
            .Header(() =>
            {
                // The Layout header template.
                Html.Kendo().MobileNavBar()
                    .Content(navbar =>
                    {
                        %>
                        <%: Html.Kendo().MobileBackButton()
                                .Align(MobileButtonAlign.Left)
                                .HtmlAttributes(new { @class = "nav-button" })
                                .Text("Back")
                        %>
                        <%: navbar.ViewTitle("iOS Platform")%>
                        <%
                    })
                    .Render();
            })
            .Footer(() =>
            {
                // The Layout footer template.
                Html.Kendo().MobileTabStrip()
                    .Items(items => {
                        items.Add().Icon("contacts").Text("Profile");
                        items.Add().Icon("settings").Text("Settings");
                    })
                    .Render();
            })
            .Render();
        %>
    
        @(Html.Kendo().MobileLayout()
            .Name("layout")
            .Platform("ios")
            .Header(obj =>
                Html.Kendo().MobileNavBar()
                    .Content(navbar =>
                        @<text>
                            @(Html.Kendo().MobileBackButton()
                                .Align(MobileButtonAlign.Left)
                                .HtmlAttributes(new { @class = "nav-button" })
                                .Url(Url.RouteUrl(new { controller = "suite" }))
                                .Text("Back"))
    
                            @navbar.ViewTitle("iOS Platform")
                        </text>)
            )
            .Footer(obj =>
                Html.Kendo().MobileTabStrip()
                    .Items(items => {
                        items.Add().Icon("contacts").Text("Profile");
                        items.Add().Icon("settings").Text("Settings");
                    })
            )
        )
    
  4. Add the View that will use the Layout.

        <% Html.Kendo().MobileView()
            .Name("layoutView")
            .Layout("layout") // the `Name` of the layout
            .Content(() =>
            {
                %>
                <p>
                    This examples shows the platform specific layouts.
                    Change the OS to see how the header and footer changes.
                </p>
                <%
            })
            .Render();
        %>
    
        @(Html.Kendo().MobileView()
            .Name("layoutView")
            .Layout("layout") // the `Name` of the layout
            .Content(
                @<text>
                    <p>
                        This examples shows the platform specific layouts.
                        Change the OS to see how the header and footer changes.
                    </p>
                </text>)
        )
    
  5. Initialize the mobile application.

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

Events

You can subscribe to all hybrid Layout events.

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

    <%: Html.Kendo().MobileLayout()
            .Name("MobileLayout")
            .Events(events => events
                .Show("onShow")
            )
    %>

    <script>
        function onShow() {
            // Handle the show event.
        }
    </script>
    @(Html.Kendo().MobileLayout()
            .Name("MobileLayout")
            .Events(events => events
                .Show("onShow")
            )
    )

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

Referencing Existing Instances

You can reference a hybrid Layout instance by using the code from the following example. Once a reference is established, use the hybrid Layout client-side API to control its behavior.

@(Html.Kendo().MobileLayout()
        .Name("MobileLayout")
)
<script>
    $(function() {
        // The Name() of the Layout is used to get its client-side instance.
        var layout = $("#MobileLayout").data("kendoMobileLayout");
    });
</script>

See Also

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