Hi Fabio,
We have achieved your requirement (passing rotator values
from controller to view) by using “ContentTemplate” which is used in “Items”
property of rotator component .We have maintained the rotator image, title and
text values in the generic list and the list values are passed from controller to the view as shown
below code,
[RotatorController.cs] List<data> Values = new List<data>(); public ActionResult Index() { Values.Add(new data { Title = "Beautiful Bird", Image = "../Images/rotator/bird.jpg", Text = "Tablets are equipped with sensors, including cameras,
microphone, accelerometer and touchscreen" }); Values.Add(new data { Title = "Rose", Image = "../Images/rotator/rose.jpg",Text="Flowers vary in size and shape and are usually large and
showy,There are over 100 species"}); Values.Add(new data { Title = "Nature", Image = "../Images/rotator/nature.jpg", Text = "Nature, in the broadest sense, is equivalent to the natural,
physical, or material world or universe." }); Values.Add(new data { Title = "Snow Fall", Image = "../Images/rotator/snowfall.jpg", Text = "Mt. Baker ski area
in Washington State has the world record for snowfall at 1,140 inches of snow
in the 1998/1999 winter season" }); Values.Add(new data { Title = "Credit Card", Image = "../Images/rotator/card.jpg", Text = "A credit card is a payment card issued to users as a system of
payment.It allows the cardholder to pay for goods and services based on the
holder's promise to pay for them" }); ViewBag.dataSource =
Values; return View(Values); } |
And in the view, we can get the list values of image, title
and text in “Model” and processed as shown below code snippet,
[Index.cshtml] @Html.EJ().Rotator("sliderContent").Items(itemElement => { foreach (var data in Model) {
itemElement.Add().ContentTemplate(@<div> <div class="leftPanel"> <img src="@Url.Content(@data.Image)" /> </div> <div class="rightPanel
blck"> <div class="contentPanel">@data.Title </div> <ul> <li>@data.Text</li> </ul> </div> </div>); } }).SlideWidth("700px").SlideHeight("300px") |
Also, we have prepared the sample based on this and it is
available under the following location,
Sample Location: Sample
Kindly
let us know if you have any queries.
Regards,
Kasithangam