c# - Image not visible while using dynamic image source - MVC5 -


i trying create image slideshow using mvc5. here model class:

public class imageslider {     public string source { get; set; }     public string imagename { get; set; }     public string title { get; set; } } 

for model, i'd created controller , action within:

public actionresult _imageslider() {     return view(new list<imageslider> {        new imageslider { source = "~/_slider/images/google.jpg" },        new imageslider { source = "~/_slider/images/googleplus.jpg" },        new imageslider { source = "~/_slider/images/facebook.jpg" }     }); } 

and here partial view:

<div class="cycle-slideshow" data-cycle-fx="scrollhorz" data-cycle-pause-on-hover="true">     @foreach (var item in model)     {         <img src="@item.source" />     } </div> 

now problem when create image tag above, not see image while can see in page source these elements have beeen created. if create these tags in html, images visible. example:

<div class="cycle-slideshow" data-cycle-fx="scrollhorz" data-cycle-pause-on-hover="true">     <img src="~/_slider/images/google.jpg" />     <img src="~/_slider/images/googleplus.jpg" />     <img src="~/_slider/images/facebook.jpg" /> </div> 

i know missing small thing here couldn't figure out what. can please me?

you need use @url.content this, change view.

 @foreach (var item in model)     {         <img src="@url.content(item.source)" />      } 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -