Getting Started with ASP.NET Core Carousel Control
23 Jul 20265 minutes to read
This section briefly explains how to include the ASP.NET Core Carousel control in your ASP.NET Core Web App using Visual Studio.
Create 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.
Install the required ASP.NET Core packages
To add ASP.NET Core Carousel control in the app, open the NuGet package manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), then search and install Syncfusion.AspNetCore.Navigations and Syncfusion.AspNetCore.Themes. All Syncfusion ASP.NET Core packages are available in nuget.org. See the NuGet packages topic for more details.
Alternatively, you can install the same packages using the Package Manager Console with the following commands.
Install-Package Syncfusion.AspNetCore.Navigations -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.Navigations and Syncfusion.AspNetCore.Base tag helpers.
@addTagHelper *, Syncfusion.AspNetCore.Navigations
@addTagHelper *, Syncfusion.AspNetCore.BaseAdd stylesheet and script resources
The theme stylesheet and script can be referenced from NuGet through Static Web Assets. Include the stylesheet and script references inside the <head> of ~/Pages/Shared/_Layout.cshtml file.
<head>
...
...
<link rel="stylesheet" href="_content/Syncfusion.AspNetCore.Themes/styles/fluent2.css" />
<script src="_content/Syncfusion.AspNetCore.Navigations/scripts/sf-carousel.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 shown below.
<body>
...
<!-- Syncfusion ASP.NET Core Script Manager -->
<ejs-scripts></ejs-scripts>
</body>Add the ASP.NET Core Carousel control
Add the ASP.NET Core Carousel control in the ~/Pages/Index.cshtml file.
<div class="col-lg-12 control-section default-carousel-section">
<div class="e-sample-resize-container carousel-sample">
<ejs-carousel id="defaultCarousel" cssClass="default-carousel">
<e-carousel-items>
<e-carousel-item template="#templateItem1"></e-carousel-item>
<e-carousel-item template="#templateItem2"></e-carousel-item>
<e-carousel-item template="#templateItem3"></e-carousel-item>
<e-carousel-item template="#templateItem4"></e-carousel-item>
<e-carousel-item template="#templateItem5"></e-carousel-item>
</e-carousel-items>
</ejs-carousel>
</div>
</div>
<style>
.default-carousel-section .carousel-sample {
margin: 0 auto 2em;
max-width: 500px;
height: 300px;
}
.default-carousel .e-carousel-items .e-carousel-item .img-container {
height: 100%;
}
.default-carousel .e-carousel-items .e-carousel-item .img-caption {
bottom: 4em;
color: #fff;
font-size: 12pt;
height: 2em;
position: relative;
padding: 0.3em 1em;
text-align: center;
width: 100%;
}
</style>
<script id="templateItem1" type="text/x-template">
<figure class="img-container">
<img src="https://ej2.syncfusion.com/aspnetcore/css/carousel/images/bridge.jpg" alt="bridge" style="height:100%; width: 100%" />
<figcaption class="img-caption">Golden Gate Bridge, San Francisco</figcaption>
</figure>
</script>
<script id="templateItem2" type="text/x-template">
<figure class="img-container">
<img src="https://ej2.syncfusion.com/aspnetcore/css/carousel/images/trees.jpg" alt="spring_trees" style="height:100%; width: 100%" />
<figcaption class="img-caption">Spring Flower Trees</figcaption>
</figure>
</script>
<script id="templateItem3" type="text/x-template">
<figure class="img-container">
<img src="https://ej2.syncfusion.com/aspnetcore/css/carousel/images/waterfall.jpg" alt="waterfall" style="height:100%; width: 100%" />
<figcaption class="img-caption">Oddadalen Waterfalls, Norway</figcaption>
</figure>
</script>
<script id="templateItem4" type="text/x-template">
<figure class="img-container">
<img src="https://ej2.syncfusion.com/aspnetcore/css/carousel/images/sea.jpg" alt="sea" style="height:100%; width: 100%" />
<figcaption class="img-caption">Anse Source d'Argent, Seychelles</figcaption>
</figure>
</script>
<script id="templateItem5" type="text/x-template">
<figure class="img-container">
<img src="https://ej2.syncfusion.com/aspnetcore/css/carousel/images/rocks.jpeg" alt="rocks" style="height:100%; width: 100%" />
<figcaption class="img-caption">Stonehenge, England</figcaption>
</figure>
</script>Press Ctrl+F5 (Windows) or ⌘+F5 (macOS) to launch the application. The ASP.NET Core Carousel control will render in your default web browser.

NOTE