asp.net mvc - How to have razor syntax inside of an image src tag -


i have list of images in application , there list of centers each have images attached specific centers. trying pull specific image specific center in foreach loop , need set variable image number.

@foreach (var in model.galleryimagemediaids)          {             <div class="carousel-item col-md-4 @active">`enter code here`                 <img class="img-fluid mx-auto d-block"                  src="/images/center/home/gallerycardimages/@i.jpg" alt="slide 1">             </div>         } 

i trying set image number in source how have razor represent number of image? if image according center 42 display 42. @i not work.

wrap c# variable in explicit code block (@( , )).

<img class="img-fluid mx-auto d-block"                  src="/images/center/home/gallerycardimages/@(i).jpg" alt="slide 1" /> 

assuming i int value has corresponding image in specifid location (ex :/images/center/home/gallerycardimages/1.jpg)


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -