This section briefly explains about how to create a simple DropDownButton 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.
To create DropDownButton add the ejs-dropdownbutton
tag with id attribute as element
in your Index.cshtml page.
<ejs-dropdownbutton id="element" content="Edit" items="ViewBag.items"></ejs-dropdownbutton>
ViewBag.items
variable is used for bounding the items
property in view page.
Populate the action items in SplitButton
by using the items
property. Here, the JSON values are passed to the
DropDownButton component are generated in default.cs
and assigned to ViewBag
variable.
public IActionResult Index()
{
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.
After successful compilation of your application, simply press F5
to run the application.
The following example shows a basic DropDownButton.
<ejs-dropdownbutton id="element" content="Edit" items="ViewBag.items"></ejs-dropdownbutton>
public ActionResult Index()
{
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();
}