문제

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