Mixed Markup Razor Syntax

MVC 5.1

I have a photo id in my model. Model.PhotoId

When I try to mix it with HTML, an error message appears with an error

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

Now I tell Razor about the completion of PhotoId and it started with " .jpg "

+3
source share
1 answer

You can always use a character @with an argument. This is really my preferred method when mixing razors.

<img src="/path/path/@(Model.PhotoId).jpg"/>
+5
source

All Articles