Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>About your question. Technically, the repeater is not 'taking' images. It is generating CSS, with a reference to the background image. The browser displaying the page is then responsible for resolving the path and retrieving/displaying the images. In this case, the images are located 'up' a few directories from the location on which the page is found.</p> <p>For serving images stored in a database, you have a few options.</p> <p>The most common approach is to build an image handler; a simple ashx generic handler does the trick nicely.</p> <p>Make the handler accept a productId via query string, grab the blob from the database using the productId, then write the blob with correct content type out to the response stream.</p> <p>Once the handler is complete, you can reference the images by referring to the handler: </p> <pre><code>background-image: url('&lt;%# Eval("ProductID", "/ImageHandler.ashx?ProductId={0}") %&gt;');"&gt; </code></pre> <p>Edit: In response to your comment, a quick and dirty handler would look similar to this. Obviously, you would need to add the actual logic to get the blob from the database.</p> <pre><code>public class ImageHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { int productId; if (!int.TryParse(context.Request["productId"], out productId)) { context.Response.End(); return; } byte[] blob = null; // get blob from DB context.Response.ContentType = "image/jpeg"; context.Response.BinaryWrite(blob); context.Response.End(); } public bool IsReusable { get { return false; } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload