Reputation: 37
(Asp.Net) I'm keeping css properties in database table but when I want to display them in view like this:
style="margin-top: @Model.Settings.MarginTop px;"
I have a problem with space between value and px.
Yes I know I can add "px" inside get or write something like this below but I'm sure there is simple way.
style="margin: @Html.Encode(Model.Settings.MarginTop)px"
Upvotes: 2
Views: 412
Reputation: 1041
You should also be able to use string.Format:
style="margin-top:@string.Format("{0}px", Model.Settings.MarginTop)"
Upvotes: 1
Reputation: 18873
Try using @()
as shown :-
style="margin-top: @(Model.Settings.MarginTop)px;"
Upvotes: 2