Getting Started with ASP.NET MVC Avatar Control

5 Jun 20241 minute to read

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

Prerequisites

System requirements for ASP.NET MVC controls

Create ASP.NET web application with HTML helper

Add stylesheet

Here, the theme is referred using CDN inside the <head> of ~/Views/Shared/_Layout.cshtml file as follows,

<head>
    ...
    <!-- Syncfusion ASP.NET MVC controls styles -->
    <link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/27.2.2/fluent.css" />
</head>

NOTE

Checkout the Themes topic to learn different ways (CDN, NPM package, and CRG) to refer styles in ASP.NET MVC application, and to have the expected appearance for Syncfusion ASP.NET MVC controls.

Add ASP.NET MVC Avatar control

Now, add the Syncfusion ASP.NET MVC Avatar control in ~/Home/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("~/Content/avatar/images/pic01.png"));
    margin: 2px;
}
</style>

Press Ctrl+F5 (Windows) or +F5 (macOS) to run the app. Then, the Syncfusion ASP.NET MVC Avatar control will be rendered in the default web browser.

ASP.NET MVC Avatar Control

NOTE

View Sample in GitHub.

See also

Types of Avatar