سؤال

MVC 5.1

I have the id of a photo in my Model. Model.PhotoId

When I try to mix it into the HTML, there is a failed error message

 <img src="/path/path/@Model.PhotoId.jpg"/>

Now do I tell Razor that the PhotoId has ended and the ".jpg" has begun?

هل كانت مفيدة؟

المحلول

You can always use the @ character with an argument as well. This is actually my preferred method when mixing razor in.

<img src="/path/path/@(Model.PhotoId).jpg"/>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top