Hi,
I'm finding it difficult to pass in the id and the imageUrl values from a database into an image tag, as shown below
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<RetailUploader.Website.Models.ViewModels.Images>>" %>
<p class="CreateButtonStyle">
<%= Html.ActionLink("Create New", "Create", null, new { @class = "createImage", title = "Create Image" })%>
</p>
<table>
<tr>
<th>
card Image
</th>
</tr>
<% foreach (var item in Model)
{ %>
<tr>
<td>
<img src="~/Uploads/" + <%: item.Id %> + "/" + <%: item.ImageUrl %> + "") alt="" />
</td>
</tr>
<% } %>
</table>
When the page renders, nothing displays apart from the table.
Is this the best way to render an image from a database?
Thanks,
Nick
Thanks for your help, I have been able to successfully get the ImageUrl to render on the page, using the below code:
Controller;
public ActionResult WebBackground(int id = 3)
{
return PartialView("WebBackground
}
User Control (Partial)
WebBackground.cshtml
@model MvcMusicStore.Models.ViewM
@Url.Content("~/Content/me
View
<style type="text/css">
.header { background: url(@Html.Action("WebBackg
</style>
This seems to work, there maybe better ways to tackle this problem, but this solution allows me to easily render a ImageUrl from the database and store the image files locally on the web server.
Thanks,
Nick