I am facing an issue trying to dynamically retrieve an image from my hard drive. Despite creating the dynamic path correctly, the image is not displaying.
The root cause of this problem lies in the fact that I am developing a back-end system for a website. The backend will reside on the same hard drive but it needs access to images uploaded by users.
This functionality is essential for us to review user uploads before making them live on the website.
Although I initially used this code on the main site and modified it for the backend, it seems to be non-functional.
Upon page display, the image fails to load. However, if I right-click on the area where the image should appear, I can copy the link and manually enter it into the address bar to view the image. It's quite perplexing!
I would greatly appreciate if someone could take a look at my code and pinpoint where I might be going wrong.
Here is the snippet of code:
<div class="panel panel-default" style="background-color: #f3f3f3;">
<div class="panel-body">
<asp:DataList ID="_propertyImagesList" runat="server" RepeatColumns="4" RepeatDirection="Horizontal" CellPadding="16">
<ItemTemplate>
<div class="popup-gallery">
<a id="imageLink" href='<%# Eval("ImagePath","file:///C:/Development/main website/main website/PropertyImages/{0}") %>' runat="server" class="thumbnail" style="margin: 10px; min-height: 140px; min-width: 140px;">
<asp:Image ID="_propertyImage" ImageUrl='<%# Bind("ThumbPath", "file:///C:/Development/main website/main website/PropertyImages/{0}") %>' runat="server" CssClass="img-responsive" />
</a>
</div>
</ItemTemplate>
</asp:DataList>
</div>
</div>
c#
protected void GetPropertyImages(int propertyId)
{
SqlCommand cmd = new SqlCommand("GetPropertyImages", conn);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
SqlDataReader rdr;
cmd.Parameters.Add("@PropertyId", System.Data.SqlDbType.Int).Value = propertyId;
conn.Open();
rdr = cmd.ExecuteReader();
_propertyImagesList.DataSource = rdr;
_propertyImagesList.DataBind();
rdr.Close();
conn.Close();
}