Click here to Skip to main content
15,851,711 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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;
Updated 14-May-12 0:39am
Sandeep Mewara 14-May-12 5:39am    
You shared this code, now what are we suppose to do with it? any issue?
subhendu kumar 14-May-12 6:48am    
this code is not working....pls tell me how can i solve it?

1 solution

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";

In your Aspx Page
img1.ImageUrl = "~/Handler.ashx";

That's It... Hope it is helpfull to you...
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900