Reputation: 1120
im trying to use razor to generate a url like this
<img id="currentPic" src="/content/img/@Html.Raw(Model.user.defaultImage).png" />
but the .png bit is being added to the @htmlraw syntax and is not compiling. I know i need to tell the page that @htmlraw is over. I tried using ; which worked - but the ; was also displayed in the string when displayed.
How can i get it so it would display like this. When Model.user.defaultImage = random1
<img id="currentPic" src="/content/img/random1.png" />
thanks
Upvotes: 0
Views: 70
Reputation: 9901
This feels like a hack, but works:
<img id="currentPic" src="/content/img/@Html.Raw(Model.user.defaultImage + ".png")" />
Upvotes: 0
Reputation: 133433
I think you don't need Html.Raw
, just use
<img id="currentPic" src="/content/img/@(Model.user.defaultImage).png" />
Upvotes: 0
Reputation: 6413
try adding a new set of parenthesis
<img id="currentPic" src="/content/img/@(Html.Raw(Model.user.defaultImage)).png" />
Upvotes: 1