Search results

Getting Started

This section briefly explains about how to create a simple SplitButton in your ASP.NET Core application. You can refer ASP.NET Core Getting Started documentation page for introduction part of the system requirements and configure the common specifications.

Add SplitButton to the project

To create SplitButton add the ejs-splitbutton tag with id attribute as element in your Index.cshtml page.

tagHelper
<ejs-splitbutton id="element" content="Paste" items="@ViewBag.items"></ejs-splitbutton>

ViewBag.items variable is used for bounding the items property in view page.

Bind dataSource

Populate the action items in SplitButton by using the items property. Here, the JSON values are passed to the SplitButton component are generated in HomeController.cs and assigned to ViewBag variable.

public IActionResult Index()
    {
        //define the array of JSON
        List<object> items = new List<object>();
        items.Add(new
        {
            text = "Cut"
        });
        items.Add(new
        {
            text = "Copy"
        });
        items.Add(new
        {
            text = "Paste"
        });
        ViewBag.items = items;
        return View();
    }

Output be like the below.

SplitButton Sample

Run the application

After successful compilation of your application, simply press F5 to run the application.

The following example shows a basic SplitButton.

tagHelper
default.cs
<ejs-splitbutton id="element" content="Paste" items="@ViewBag.items"></ejs-splitbutton>
public IActionResult Index()
    {
            //define the array of JSON
            List<object> items = new List<object>();
            items.Add(new
            {
                text = "Cut"
            });
            items.Add(new
            {
                text = "Copy"
            });
            items.Add(new
            {
                text = "Paste"
            });
            ViewBag.items = items;
            return View();
    }

See Also