功能需求:打开A.aspx后,页面下方有一个 img html元素,src指向一个ashx,ashx的作用就是画图输出到A.aspx
现在问题是,我在打开A.aspx后怎样传参数给ashx让它接受参数并画图片到A.aspx的img上。要传的参数在A.aspx.cs中经过处理得到,是几个数组。
请问有高手指点一下思路吗
现在问题是,我在打开A.aspx后怎样传参数给ashx让它接受参数并画图片到A.aspx的img上。要传的参数在A.aspx.cs中经过处理得到,是几个数组。
请问有高手指点一下思路吗
你的ashx要输出图片数据流,类似下面public void ProcessRequest(HttpContext context)
{
HttpResponse Response = context.Response;
Response.ClearContent();
Response.ContentType = "image/jpeg";
System.Drawing.Image img = null;//图片从哪里来
img.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
img.Dispose();
}要传参时就用js修改下src就可以了
$('img').attr('src','b.ashx?parm1=1&parm2=2');
http://www.cnblogs.com/insus/archive/2013/03/08/2950300.html
如果你不想这样,你可以用Session传值,你将数组存放于Session中,然后在ashx中获取Session
如果你不想这样,你可以用Session传值,你将数组存放于Session中,然后在ashx中获取Session关键是我们项目经理不让用Session传值,蛋疼
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ContentType = "image/png";
HttpContext.Current.Response.BinaryWrite(OutPutContent);
那不就是querystring吗?!