Question

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?

Était-ce utile?

La solution

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"/>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top