I am trying to call multiple partial views into one controller. I have a carousel that will have at least 3 slides that will be managed by a CMS. I want to be able to do a partial view for each of those slide and call them all into the home controller with an array. I know that my view will need the foreach loop but do I need a separate model for each of those partial views or will one model work? I did look at this question and answers but I think its a little different than what I am looking for (ASP.NET MVC - How to pass an Array to the view?) I've included the partial view first. The view, model and controller code. I apologize ahead of time the code is a mess. Any help would be appreciated. Thank you.
Partial View - @{
ViewData["Title"] = "_CorporateEvents";
}
<div>
@foreach (var image in Model)
{
<img width="850" height="700">
<img source src="@image.EventImages.File.Url" type="image"
alt="Your browser does not support the image tag." />
}
View--<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
</div>
<div class="item">
@Html.Partial("~/Views/Shared/_CorporateEvents.cshtml");
</div>
Model---namespace MyLink.Models
{
public class CorporateEvents
{
[JsonProperty("eventImages")]
public Asset EventImages { get; set; }
}
}
Controller ----public async Task<IActionResult> Index()
{
var qb = QueryBuilder<CorporateEvents>.New.ContentTypeIs("corporateEvents");
var entries = await _client.GetEntriesAsync(qb);
return View(entries);
}
}
}