私は次のモデルを持っています:
public class Player
{
public String ImagePath
{
get
{
return "~/Content/img/sql_error.JPG";
}
}
そして、これは私の.cshtml
ファイルです:
@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>
結果は単純なテキストです。
~/Content/img/sql_error.JPG
~/Content/img/sql_error.JPG
Sample Image asd model.ImagePath;
また、次の行を試してみましたが、機能します。
<img src="~/Content/img/sql_error.JPG" alt="Sample Image" width="300px" />
パスからその画像を表示する方法は? 設定によってイメージパスが異なる可能性はありますか? 他のアイデアはありますか?
かみそりの構文がどのように機能するかについては、今ではよくわかりません。