this is the model.
public class Player
{
public String ImagePath
{
get
{
return "~/Content/img/sql_error.JPG";
}
}
this is my .cshtml and what i tried:
@model SoulMasters.Models.Game.Player
@{
ViewBag.Title = "Game";
Layout = "~/Views/Shared/_GameLayout.cshtml";
var imagePath = @Model.ImagePath;
}
<fieldset>
<legend>Player</legend>
<div class="display-field">
@Html.DisplayFor(model => model.ImagePath)
</div>
@imagePath
<div style="padding:10px;">
<img src=@imagePath alt="Sample Image" width="300px" />
<img alt="asd" >
model.ImagePath;
</img>
</div>
</fieldset>
the result is simple text:
~/Content/img/sql_error.JPG
~/Content/img/sql_error.JPG
Sample Image asd model.ImagePath;
i also tried:
<img src="~/Content/img/sql_error.JPG" alt="Sample Image" width="300px" />
and this works
how to display that image from path? the model image path can be different, based on settings. any other ideas?
i don't really get it now on how razor syntax works.
thanks, Gabriel Sas