// bu kod Controller a eklenecek....Sonra örneğin list sayfasındaki resim kısmında çağrılacak(aşağıdaki gibi)resim göster***************
public ActionResult ViewPhoto(int id)
{
var photo = db.Categories.Find(id).Picture;
return File(photo, "image/jpeg"); // you'll need to specify the content type based on your picture
}
// resim gösteri çağır.
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.CategoryName)
</th>
<th>
@Html.DisplayNameFor(model => model.Description)
</th>
<th>
@Html.DisplayNameFor(model => model.Picture)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.CategoryName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
<img src='@Url.Action("ViewPhoto", new { id = item.CategoryID })' />
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.CategoryID }) |
@Html.ActionLink("Details", "Details", new { id=item.CategoryID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.CategoryID })
</td>
</tr>
}
</table>
public ActionResult ViewPhoto(int id)
{
var photo = db.Categories.Find(id).Picture;
return File(photo, "image/jpeg"); // you'll need to specify the content type based on your picture
}
// resim gösteri çağır.
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.CategoryName)
</th>
<th>
@Html.DisplayNameFor(model => model.Description)
</th>
<th>
@Html.DisplayNameFor(model => model.Picture)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.CategoryName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
<img src='@Url.Action("ViewPhoto", new { id = item.CategoryID })' />
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.CategoryID }) |
@Html.ActionLink("Details", "Details", new { id=item.CategoryID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.CategoryID })
</td>
</tr>
}
</table>
Yorumlar
Yorum Gönder