This is my code, all it does is clear the web page and draw the image, so the rest of the form disappears! I need to show the image inside the form.
This is my User
Response.Clear();
is deleting all the buffered content (i.e. everything in your page).
Instead of a user control to display a dynamic image, consider an HTTP handler (.ashx
), like this:
ImageHandler.ashx:
public class ImageHandler : System.Web.IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
// Logic to get byte array here
byte[] buffer = WhateverLogicNeeded;
context.Response.ContentType = "image/jpeg";
context.Response.OutputStream.Write(buffer, 0, buffer.Length);
}
public bool IsReusable
{
get { return false; }
}
}
Then in your .aspx
page:
Note: If you want a specific image, then you can pass a query string (i.e. image ID) to the handler and have the byte array logic account for using the query string value.