Getting Started with ASP.NET Core Mention Control
23 Jul 20264 minutes to read
This section briefly explains how to include the ASP.NET Core Mention control in your 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 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 ASP.NET Core Mention 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.DropDowns and Syncfusion.AspNetCore.Themes packages. All Syncfusion ASP.NET Core packages are available on nuget.org. See the NuGet packages topic for details.
Alternatively, you can install the same packages using the Package Manager Console with the following command.
Install-Package Syncfusion.AspNetCore.DropDowns -Version 34.1.29
Install-Package Syncfusion.AspNetCore.Themes -Version 34.1.29Add 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.DropDowns Tag Helpers.
@addTagHelper *, Syncfusion.AspNetCore.Base
@addTagHelper *, Syncfusion.AspNetCore.DropDownsAdd stylesheet and script resources
The theme stylesheet and script can be referenced from CDN. Include the stylesheet and script references inside the <head> of ~/Pages/Shared/_Layout.cshtml.
<head>
...
@* ASP.NET Core controls styles *@
<link rel="stylesheet" href="_content/Syncfusion.AspNetCore.Themes/styles/fluent2.css" />
@* ASP.NET Core controls scripts *@
<script src="_content/Syncfusion.AspNetCore.DropDowns/scripts/sf-mention.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>
...
@* ASP.NET Core Script Manager *@
<ejs-scripts></ejs-scripts>
</body>Add ASP.NET Core Mention Control
Add the ASP.NET Core Mention control in the ~/Pages/Index.cshtml file.
@{
string[] data = new string[] { "Selma Rose", "Garth", "Robert", "William", "Joseph" };
char nameMentionChar = '@';
}
<label style="font-size: 15px; font-weight: 600;">Comments</label>
<div id="defaultMention" placeholder="Type @@ and tag user" style="min-height: 100px; border: 1px solid #D7D7D7; border-radius: 4px; padding: 8px; font-size: 14px; width: 600px;"></div>
<ejs-mention id="default" target="#defaultMention" mentionChar="@nameMentionChar" dataSource="@data"></ejs-mention>Run the application
Press Ctrl+F5 (Windows) or ⌘+F5 (macOS) to launch the application. The ASP.NET Core Mention control will render in your default web browser.

Binding data source
After initialization, populate the ASP.NET Core Mention with data using the dataSource property with an array of string values.
@{
string[] data = new string[] { "Selma Rose", "Garth", "Robert", "William", "Joseph" };
char nameMentionChar = '@';
}
<label style="font-size: 15px; font-weight: 600;">Comments</label>
<div id="defaultMention" placeholder="Type @@ and tag user" style="min-height: 100px; border: 1px solid #D7D7D7; border-radius: 4px; padding: 8px; font-size: 14px; width: 600px;"></div>
<ejs-mention id="default_data" mentionChar="@nameMentionChar" dataSource="@data" target="#defaultMention"></ejs-mention>Display mention character
By using the showMentionChar property, the text content can be displayed along with the mention character. You can customize the mention character by using the mentionChar property in the ASP.NET Core Mention control.
NOTE
By default, the mentionChar is
@and the showMentionChar property is disabled.
The following example, displays the text content along with the mention character configured as #.
@{
string[] data = new string[] { "Selma Rose", "Garth", "Robert", "William", "Joseph" };
char nameMentionChar = '#';
}
<label style="font-size: 15px; font-weight: 600;">Comments</label>
<div id="defaultMention" placeholder="Type # and tag user" style="min-height: 100px; border: 1px solid #D7D7D7; border-radius: 4px; padding: 8px; font-size: 14px; width: 600px;"></div>
<ejs-mention id="showMention" dataSource="@data" mentionChar="@nameMentionChar" showMentionChar="true" target="#defaultMention"></ejs-mention>