Reputation: 3256
In my main view i have following:
<body style="background-image: url(../Content/themes/base/images/sos.png)">
Instead of using string url here i want admin to have access to this url by using AdminModel. Something like this:
<body style="background-image: @AdminModel.BackgroundImage>
My AdminModel currently look like this:
public class AdminModel
{
public int DateId { get; set; }
public DateTime Date { get; set; }
public string BackgroundPath { get; set; }
}
Where DateId and Date are fields of a DateTime table. I dont want to add BackgroundPath as a table field because it will only carry one value. So is there a better way to achieve this? So that admin can change background url when they want to?
Upvotes: 1
Views: 235
Reputation: 4732
You will have to use something very similar to this:
<body style="background-image: url(@(AdminModel.BackgroundImage))">
On the other hand, you might want to use better (subjective) solution presented here: Action Image MVC3 Razor
Hope this helps
Upvotes: 2