MVC Razor use ViewBag as part of dynamic Image link -
i've got mvc application , i've got viewbag list of items. i've got list using razor show in modal popup , hoping use said list, dynamically display image each item in list
i'm hoping along lines of "~/images/ + @viewbag.list[i] + .jpg"
does know of way achieve i've not had luck far?
any assistance on accomplishing appreciated!
thanks in advance paul
@foreach(var item in viewbag.list) { <img src="~/images/@(item).jpg" /> }
should work you. issue running not need the:
+ @viewbag.list[i] +
@viewbag.list[i] work inline without string concatenation.
Comments
Post a Comment