Getting Started with ASP.NET Core Speed Dial Control

23 Jul 20266 minutes to read

This section briefly explains how to include the ASP.NET Core Speed Dial control in an ASP.NET Core application using Visual Studio.

Create an ASP.NET Core Web App with Razor Pages

Create an ASP.NET Core Web App using Visual Studio via Microsoft Templates or the Syncfusion® ASP.NET Core Extension. For detailed instructions, refer to the ASP.NET Core Web App Getting Started documentation.

Install the required ASP.NET Core packages

To add the ASP.NET Core Speed Dial control in the app, open the NuGet package manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), search for and install the Syncfusion.AspNetCore.Buttons and Syncfusion.AspNetCore.Themes packages. All Syncfusion ASP.NET Core packages are available in nuget.org. See the NuGet packages topic for details.

Alternatively, you can install the same packages using the Package Manager Console with the following commands.

Install-Package Syncfusion.AspNetCore.Buttons -Version 34.1.29
Install-Package Syncfusion.AspNetCore.Themes -Version 34.1.29

Add the ASP.NET Core Tag Helpers

After the packages are installed, open the ~/Pages/_ViewImports.cshtml file and import the Syncfusion.AspNetCore.Base and Syncfusion.AspNetCore.Buttons Tag Helpers.

@addTagHelper *, Syncfusion.AspNetCore.Base
@addTagHelper *, Syncfusion.AspNetCore.Buttons

Add stylesheet and script resources

The theme stylesheet and script can be referenced from Static Web Assets. Include the stylesheet and script references inside the <head> of ~/Pages/Shared/_Layout.cshtml.

<head>
    ...
    <!-- Syncfusion ASP.NET Core controls styles -->
    <link rel="stylesheet" href="_content/Syncfusion.AspNetCore.Themes/styles/fluent2.css" />
    <!-- Syncfusion ASP.NET Core Speed Dial control script -->
    <script src="_content/Syncfusion.AspNetCore.Buttons/scripts/sf-speed-dial.min.js"></script>
</head>

Register the Script Manager

Open the ~/Pages/Shared/_Layout.cshtml file and register the script manager <ejs-scripts> at the end of the <body> element as follows.

<body>
    ...
    <!-- Syncfusion ASP.NET Core Script Manager -->
    <ejs-scripts></ejs-scripts>
</body>

Add ASP.NET Core Speed Dial control

Add the ASP.NET Core Speed Dial control in the ~/Pages/Index.cshtml file.

@using Syncfusion.EJ2.Buttons;
@{
    List<SpeedDialItem> items = new List<SpeedDialItem>();
    items.Add(new SpeedDialItem
    {
        Text="Cut"
    });
    items.Add(new SpeedDialItem
    {
        Text="Copy"
    });
    items.Add(new SpeedDialItem
    {
        Text="Paste"
    });
}

<div id="target" style="min-height:200px; position:relative; width:300px; border:1px solid;">
    <ejs-speeddial id="speeddial" target="#target" content="Edit" items="items"></ejs-speeddial>
</div>

Run the application

Press Ctrl+F5 (Windows) or +F5 (macOS) to launch the application. The ASP.NET Core Speed Dial will render in your default web browser.

ASP.NET Core Speed Dial Control

Positioning

The ASP.NET Core Speed Dial can be positioned using the position property. The speed dial is positioned based on the target, if target is defined else positioned based on the browser viewport. The position values are TopLeft, TopCenter, TopRight, MiddleLeft, MiddleCenter, MiddleRight, BottomLeft, BottomCenter and BottomRight.

@{
    List<SpeedDialItem> items = new List<SpeedDialItem>();
    items.Add(new SpeedDialItem
    {
        IconCss="e-icons e-cut",
        Text="Cut"
    });
    items.Add(new SpeedDialItem
    {
        IconCss="e-icons e-copy",
        Text="Copy"
    });
    items.Add(new SpeedDialItem
    {
        IconCss="e-icons e-paste",
        Text="Paste"
    });
}

<div id="target" style="min-height:200px; position:relative; width:300px; border:1px solid;">
    <ejs-speeddial id="speeddial" target="#target" position="BottomLeft" content="Edit" items="items"></ejs-speeddial>
</div>

ASP.NET Core Speed Dial Control

Linear and radial display modes

You can use the mode property to either display the menu in linear order like a list or like a radial menu in radial (circular) direction.

@{
    List<SpeedDialItem> items = new List<SpeedDialItem>();
    List<SpeedDialItem> items1 = new List<SpeedDialItem>();
    items.Add(new SpeedDialItem
    {
        IconCss="e-icons e-cut"
    });
    items.Add(new SpeedDialItem
    {
        IconCss="e-icons e-copy"
    });
    items.Add(new SpeedDialItem
    {
        IconCss="e-icons e-paste"   
    });
    items1.Add(new SpeedDialItem
    {
        IconCss="e-icons e-cut",
        Text="Cut"
    });
    items1.Add(new SpeedDialItem
    {
        IconCss="e-icons e-copy",
        Text="Copy"
    });
    items1.Add(new SpeedDialItem
    {
        IconCss="e-icons e-paste",
        Text="Paste"
    });
}

<div id="target" style="min-height:200px; position:relative; width:300px; border:1px solid;">
    <ejs-speeddial id="speeddial" target="#target" position="BottomLeft" content="Edit" items="items" mode="Radial" openIconCss="e-icons e-edit"></ejs-speeddial>
    <ejs-speeddial id="speeddial1" target="#target" position="BottomRight" content="Edit" items="items1" mode="Linear" openIconCss="e-icons e-edit"></ejs-speeddial>
</div>

ASP.NET Core Speed Dial Control

ASP.NET Core Speed Dial Control

Clicked event

The ASP.NET Core Speed Dial control triggers the clicked event when an action item is clicked. You can use this event to perform the required action.

@{
    List<SpeedDialItem> items = new List<SpeedDialItem>();
    items.Add(new SpeedDialItem
    {
        IconCss="e-icons e-cut",
        Text="Cut"
    });
    items.Add(new SpeedDialItem
    {
        IconCss="e-icons e-copy",
        Text="Copy"
    });
    items.Add(new SpeedDialItem
    {
        IconCss="e-icons e-paste",
        Text="Paste"
    });
}

<div id="target" style="min-height:200px; position:relative; width:300px; border:1px solid;">
    <ejs-speeddial id="speeddial" clicked="clicked" target="#target" openIconCss="e-icons e-edit" items="items"></ejs-speeddial>
</div>

<script>
    function clicked(args) {
        alert(args.item.text + " is clicked");
    }
</script>

ASP.NET Core Speed Dial Control

See also