Last post Sep 19, 2018 02:36 AM by Yuki Tao
Sep 18, 2018 07:09 AM|RioDD|LINK
I have a view that it is using some model Image1. In Image1 I have field name src, height and width. The controller is sending the model data to the view. Now the problem is in Razor. How do I put these values directly in the view in
<img src="" width="" height=""/>
Sep 18, 2018 11:32 AM|RioDD|LINK
<img src="@Html.ValueFor(x=>x.ImageUrl)"/> and width and height put in style
Sep 19, 2018 02:36 AM|Yuki Tao|LINK
Also,you could code like:
1.Url.Content is used when you wish to resolve a URL for any file or resource on your site and you would pass it the relative path:
2.@Html.ValueFor(x => x.PropertyName) It will allow you to customize the way the value is presented, and then have a consistent format across your whole site.
@Model.PropertyName is literally getting the value of the property directly, calling ToString() on it, and HTML escaping the result. No other formatting will take place.
public decimal PropertyName = 1111.22;
@Html.ValueFor(x => x.PropertyName) => "£1,111.22"
@Model.PropertyName => "1111.22"