Getting Started with ASP.NET Core Avatar Control

23 Jul 20262 minutes to read

This section explains how to include ASP.NET Core Avatar control in your ASP.NET Core application using Visual Studio.

Create ASP.NET Core web application 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 ASP.NET Core package in the application

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

Alternatively, you can install the same package using the Package Manager Console with the following command.

Install-Package Syncfusion.AspNetCore.Themes -Version 34.1.29

Add stylesheet

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

<head>
    ...
    <link rel="stylesheet" href="_content/Syncfusion.AspNetCore.Themes/styles/fluent2.css" />
</head>

Add ASP.NET Core Avatar control

Add the ASP.NET Core Avatar tag helper in ~/Pages/Index.cshtml page.

<div id='element'>
    <span class="e-avatar e-avatar-xlarge"></span>
    <span class="e-avatar e-avatar-large"></span>
    <span class="e-avatar"></span>
    <span class="e-avatar e-avatar-small"></span>
    <span class="e-avatar e-avatar-xsmall"></span>
</div>

<style>
    #element {
        display: block;
        width: 300px;
        margin: 130px auto;
        border-radius: 3px;
        justify-content: center;
    }

    .e-avatar {
        background-image: url(@Url.Content("https://ej2.syncfusion.com/aspnetcore/css/avatar/images/pic01.png"));
        margin: 2px;
    }
</style>

Run the application

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

ASP.NET Core Avatar Control

NOTE

View Sample in GitHub.

See also