如何将信息传递给处理程序页面?以及如何指定将在 asp-image-control 中显示的图像?
Handler1.ashx.cs 代码:
public void ProcessRequest(HttpContext context)
{
int id1 = something //how can I pass a information to a handler page
int id2 = somthing 2 // same case
byte[] IMG = classP.RedImg(id1);
context.Response.ContentType = "image/jpg";
context.Response.BinaryWrite(IMG);
byte[] IMG2 = classP.RedImg(id2);
context.Response.ContentType = "image/jpg";
context.Response.BinaryWrite(IMG2);
}
public bool IsReusable
{
get
{
return false;
}
}
页面.aspx 代码:
<asp:Image ID="Image1" runat="server" />
<asp:Image ID="Image2" runat="server" />
Page.aspx.cs 后面的代码:
string[] data = classC.ReadClient();
int id1 = Convert.ToInt32(data[0]); //Here is id1 value
int id2 = Convert.ToInt32(data[1]); //Here is id2 value
Image1.ImageUrl = "~/Handler1.ashx?ID=" + id1.ToString();
Image2.ImageUrl = "~/Handler1.ashx?ID=" + id2.ToString();
谢谢 :]