需要在asp.net的图像控件中显示注释附件中的图像. [英] Need to display the image from annotation attachment in the image control in asp.net.

查看:75
本文介绍了需要在asp.net的图像控件中显示注释附件中的图像.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ColumnSet cols1 = new ColumnSet();
        cols1.Attributes = new string[] { "filename", "mimetype", "documentbody"};

        annotation annotationAttachment = (annotation)myCRMService.Retrieve(EntityName.annotation.ToString(), annotationId, cols1);

        String strfilecontent = annotationAttachment.documentbody.Replace(" ","+");
        String strfilename = annotationAttachment.filename;
        String strfiletype = annotationAttachment.mimetype
        img1.Src = "Handler.ashx?id="+strfilecontent+"&filename="+strfilename+"&filetype="+strfiletype;

推荐答案


在Handler.ashx中,创建一个BitMap对象,并从通过QueryString给定的路径中加载图像,并将其保存在您的内存流中,并将其转换为字节数组,并将这些字节数组作为字节内容发送到aspx页. .如下所示:

在Handler.ashx文件中
Hi,
In Handler.ashx, create a BitMap Object and Load the image from the path given through the QueryString and save it in you memory stream and convert it in to a byte array and send these byte array as the byte content to your aspx page... as shown here:

In Handler.ashx file
Bitmap objBmp = new Bitmap("[Valid File Path]");
MemoryStream ms = new MemoryStream();
objBmp.Save(ms, ImageFormat.Png);
byte[] bmpBytes = ms.GetBuffer();
context.Response.ContentType = "image/png";
context.Response.BinaryWrite(bmpBytes);



在您的Aspx页面中



In your Aspx Page

img1.ImageUrl = "~/Handler.ashx";



就这样...希望对您有帮助...



That''s It... Hope it is helpfull to you...


这篇关于需要在asp.net的图像控件中显示注释附件中的图像.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆