my images are stored on server in folder "Albums".To access images the path is "/Albums/". I have tried this code but its not working.boxes for images appear on page load but after that immediately disappear.

<asp:ListView runat="server" ID="listView">
<ItemTemplate>
<asp:Image ID="img" ImageUrl= '<%# "/" + Eval("PictureLink")%>' width ="44" height ="45" runat="server" />
</ItemTemplate>
</asp:ListView>

Dani AI

Generated

Brief diagnosis and immediate checks: the behavior described (image boxes appear briefly and then disappear) almost always comes from an incorrect client-side src or a client script that removes/hides images. Inspect the rendered <img> tag in browser DevTools (Elements/Network). If the src is wrong, the Network tab will show 404 or a redirect; copying the src into the address bar verifies whether IIS actually serves the file.

About the binding suggestions already made: ’s Eval-format trick works when the data field already contains just the file name. ’s ResolveClientUrl advice is also valid when using app-relative paths. The important distinction is that server-side binding must emit a client-visible URL (no raw "~"). For reference on formatting/eval behavior and path resolution see the Microsoft docs for Eval and VirtualPathUtility.ToAbsolute (, VirtualPathUtility.ToAbsolute).

A robust alternative is to set ImageUrl in the ListView’s item-binding handler (server side) so the final value is guaranteed correct. Example pattern (code-behind) finds the Image control, reads the data item’s picture name, and converts an app-relative path into a client path with VirtualPathUtility.ToAbsolute before assigning ImageUrl.

Troubleshooting checklist: confirm the Albums folder is deployed and readable by IIS, check case-sensitivity on non-Windows hosts, verify whether the ListView is bound on every required lifecycle event (or uses DataSourceID), and look for JavaScript/jQuery that might alter the DOM after render. If the app runs in a virtual directory, prefer ToAbsolute/ResolveUrl rather than assuming leading "/" will work.

Recommended Answers

All 2 Replies

You can use format part of Eval().

ImageUrl='<%# Eval("PictureLink","~/Albums/{0}")%>'

Hi eesha.ebaad,

I can understand how you feel when you find your image in your specified location but can't see in your page.
To fix this you might need a fully qualified URL to the specified resource suitable for use on the browser i.e.ResolveClientURL("~Your Link")

So, your code should be something like this

<asp:Image ID="img" ImageUrl= '<%# ResolveClientURL("~/" + Eval("PictureLink")) %>' width ="44" height ="45" runat="server" />

Hope this helps :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.