Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay Images as a slideshow for Mobile application using mvc4
    text
    copied!<p>Display Images as a slideshow for Mobile application using mvc4.</p> <p>i am taking the physical path of those images in to one array[] in control. and i want pass that array to view. there i want to display those images as a slide show.</p> <p>here is my code</p> <p>Controller code:</p> <pre><code> public ActionResult Index() { var imageFiles = new Mobile.Models.DisplayImages.ImageModel(); imageFiles.Images.AddRange(System.IO.Directory.GetFiles(@"E:\05-11\New Folder\Images\BannerImages\")); for (int i = 0; i &lt; imageFiles.Images.Count; i++) { // get rid of the fully qualified path name imageFiles.Images[i] = imageFiles.Images[i].Replace(@"E:\05-11\New Folder\Images\BannerImages\", "../../Images/BannerImages/"); // change the slashes for web imageFiles.Images[i] = imageFiles.Images[i].Replace('\\', '/'); } return View(imageFiles); } </code></pre> <p>Model Code:</p> <pre><code>public class DisplayImages { public class ImageModel { List&lt;string&gt; _images = new List&lt;string&gt;(); public ImageModel() { _images = new List&lt;string&gt;(); } public List&lt;string&gt; Images { get { return _images; } set { _images = value; } } } } </code></pre> <p>View Code:</p> <pre><code> @for (int imgIndex = 0; imgIndex &lt; Model.Images.Count; imgIndex++){ if (imgIndex == 0) { &lt;img class="first" src = "@Model.Images[imgIndex]" alt="No Image"/&gt; } else { &lt;img src = "@Model.Images[imgIndex]" alt="No Image"/&gt; } </code></pre> <p>}</p> <p>you can apply the styles in view file according to your requirement.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload