Reputation: 347
I am currently working on a school project and I'm not sure what is being returned and how to make the data usable. Here is the code:
Default.aspx
function GetImage(id) {
//step k. - code here
xmlHttpObj = CreateXmlHttpRequestObject();
if (xmlHttpObj) {
xmlHttpObj.open("GET", "Handler.ashx?id=" + id, true);
xmlHttpObj.send(null);
var image = document.getElementById("ProductImage");
//the response contains an array of 5419 index
}
}
Handler.ashx
public void ProcessRequest (HttpContext context)
{
int id;
if (context.Request.QueryString["id"] != null)
{
id = Convert.ToInt32(context.Request.QueryString["id"]);
context.Response.ContentType = "image/jpeg";
byte[] bufferImg = GetImage(id);
context.Response.OutputStream.Write(bufferImg, 0, bufferImg.Length);
}
}
GetImage(int id) returns "(byte[]).cmd.ExecuteScalar();", im not really sure what i am supposed to do with the information that is being passed back. I'm assuming it is the image itself? any help is appreciated. Thanks!
Upvotes: 1
Views: 2484
Reputation: 8337
why not try
function GetImage(id) {
document.getElementById("ProductImage").src="Handler.ashx?id=" + id;
}
Upvotes: 3