1
현재 학교 프로젝트를 진행하고 있으며 반환되는 내용과 데이터를 사용 가능하게 만드는 방법을 잘 모릅니다. ; ". (바이트 []) cmd.ExecuteScalar()"Handler.ashx를 사용하여 이미지 얻기
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 아이디) 결과 : 다음 코드는 나는 정말로 전달 된 정보로 무엇을 해야하는지 확신하지 못합니다. 이미지 자체라고 가정하고 있습니까? 어떤 도움을 주셔서 감사합니다. 감사!
당신을 감사하지! 매력처럼 일했습니다. 내가 다른 방식으로 해본 적이 없기 때문에 xmlHttpObject를 사용할 필요가 있다는 인상을 받았다. 항상 새로 고침을하고 나중에 기억하는 것이 좋은 방법은 항상 다른 방법입니다. –