Edit this page

Hybrid ActionSheet HtmlHelper Overview

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

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

Configuration

Below are listed the steps for you to follow when configuring the hybrid Kendo UI ActionSheet 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 hybrid Kendo UI ActionSheet to the Index view. Like most hybrid Kendo UI widgets, the ActionSheet must be initialized within the hybrid View content.

    Example
    
            <% Html.Kendo().MobileView()
                    .Name("actionsheet-view")
                    .Title("Inbox")
                    .Content(() =>
                    {
                        %>
                        <!-- Add button to open the actionsheet widget -->
                        <%: Html.Kendo().MobileButton()
                                .Name("button")
                                .Rel(MobileButtonRel.ActionSheet)
                                .Text("Reply")
                                .Url("#inboxActions")
                        %>
    
                        <% Html.Kendo().MobileActionSheet()
                            .Name("inboxActions")
                            .Popup(popup => popup.Direction(MobilePopupDirection.Left))
                            .Title("Monday Meeting:")
                            .Items(items => {
                                items.Add().Text("Reply");
                                items.Add().Text("Reply All");
                                items.Add().Text("Archive");
                            })
                            .Render();
                        %>
                        <%
                    })
                    .Render();
            %>
    
    
            @(Html.Kendo().MobileView()
                .Name("actionsheet-view")
                .Title("Inbox")
                .Content(
                    @<text>
                    <!-- Add button to open the actionsheet widget -->
                    @(Html.Kendo().MobileButton()
                        .Name("button")
                        .Rel(MobileButtonRel.ActionSheet)
                        .Text("Reply")
                        .Url("#inboxActions")
                    )
    
                    @(Html.Kendo().MobileActionSheet()
                        .Name("inboxActions")
                        .Popup(popup => popup.Direction(MobilePopupDirection.Left))
                        .Title("Monday Meeting:")
                        .Items(items => {
                            items.Add().Text("Reply");
                            items.Add().Text("Reply All");
                            items.Add().Text("Archive");
                        }))
    
                </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 ActionSheet events.

By Handler Name

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

Example

        <%: Html.Kendo().MobileActionSheet()
                .Name("MobileActionSheet")
                .Items(items => {
                    items.Add().Text("Reply").Action("replay");
                }))
                .Events(events => events
                    .Open("onOpen")
                )
        %>

        <script>
        function onOpen() {
            //Handle the open event.
        }

        function replay() {
            //Will execute when item with `Reply` title is clicked.
        }
        </script>

        @(Html.Kendo().MobileActionSheet()
                .Name("MobileActionSheet")
                .Items(items => {
                    items.Add().Text("Reply").Action("replay");
                }))
                .Events(events => events
                    .Open("onOpen")
                )
        )

        <script>
        function onOpen() {
            //Handle the open event.
        }

        function replay() {
            //Will execute when item with `Reply` title is clicked.
        }
        </script>

Reference

Instances

You can reference a hybrid ActionSheet instance by using the code from the example below. Once a reference is established, use the hybrid ActionSheet API to control its behavior.

Example
    @(Html.Kendo().MobileActionSheet()
        .Name("inboxActions")
        .Popup(popup => popup.Direction(MobilePopupDirection.Left))
        .Title("Monday Meeting:")
        .Items(items => {
            items.Add().Text("Reply");
            items.Add().Text("Reply All");
            items.Add().Text("Archive");
        }))
    <script>
    $(function() {
        //Notice that the Name() of the ActionSheet is used to get its client-side instance.
        var actionsheet = $("#inboxActions").data("kendoMobileActionSheet");
    });
    </script>

See Also