Reputation: 199
I have been trying to escape razor code so that is outputs the category in middle of the file name.
<div class="headerpost" style='background-image: url(~/CategoryImages/'@Model.Category'.jpg);'>
So that it appears like /CategoryImages/Orders.jpg in the background-image style. I have tried several escape characters & "" + none of them work.
Upvotes: 1
Views: 101
Reputation:
The format need to be
<div class="headerpost" style='background-image: url(~/CategoryImages/@(Model.Category).jpg);'>
Upvotes: 1
Reputation: 9289
<div class="headerpost" style="background-image: url('~/CategoryImages/@(Model.Category).jpg');">
Check the single quotes in this code, it should be on whole URL part.
Upvotes: 0