Mam następujący model:Jak wyświetlić obraz ze ścieżki w widoku asp.net MVC 4 i Razor?
public class Player
{
public String ImagePath
{
get
{
return "~/Content/img/sql_error.JPG";
}
}
I to jest mój .cshtml
file:
@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 [email protected] alt="Sample Image" width="300px" />
<img alt="asd" >
model.ImagePath;
</img>
</div>
</fieldset>
Wynik jest prosty tekst:
~/Content/img/sql_error.JPG
~/Content/img/sql_error.JPG
Sample Image asd model.ImagePath;
Również próbowałem następujące linia i działa:
<img src="~/Content/img/sql_error.JPG" alt="Sample Image" width="300px" />
Jak wyświetlić obraz ze ścieżki? Czy ścieżka obrazu może być inna w zależności od ustawień? Jakieś inne pomysły?
Nie rozumiem teraz, jak działa składnia maszynki do golenia.
spróbować tej '' –