i have one image control in my application i want to display the image , instead of displaying pdf or jpg images i want to see the content of the page in image control
What I have tried:
<asp:Image ID="displayImage" Style="padding: 0px" Height="86" Width="84" ImageAlign="Middle" ImageUrl='<%# "../Handlers/ImageHandlerNew.ashx?DocumentId=" + Eval("BeneficiaryDocumentId") + "&IsThumbnail=true"%>' runat="server" />
imagehanlder.ashx
public void ProcessRequest(HttpContext context)
{
string documentID = context.Request.QueryString["DocumentId"].ToString();
string isThumbnail = context.Request.QueryString["IsThumbnail"].ToString();
BizBeneficiaryDocuments bizBeneficiaryDocuments = new BizBeneficiaryDocuments();
DataTable data = bizBeneficiaryDocuments.GetImageDataByID(documentID.ToInt32());
if (data.Rows.Count > 0)
{
DataRow dr = data.Rows[0];
if (isThumbnail.Equals("true"))
{
byte[] byteData;
if (dr[0].ToString().Contains("pdf"))
{
byteData = File.ReadAllBytes(HttpContext.Current.Server.MapPath("../img/pdf_128.png"));
}
else if (dr[0].ToString().Contains("application/vnd.openxmlformats"))
{
byteData = File.ReadAllBytes(HttpContext.Current.Server.MapPath("../img/ppt_128.png"));
}
else if (dr[0].ToString().Contains("ms-word"))
{
byteData = File.ReadAllBytes(HttpContext.Current.Server.MapPath("../img/word_128.png"));
}
else if (dr[0].ToString().Contains("image"))
{
byteData = File.ReadAllBytes(HttpContext.Current.Server.MapPath("../img/images.jpg"));
}
else
{
byteData = (byte[])dr[1];
}
context.Response.BinaryWrite(byteData.MakeThumbnail(64, 64));// MakeThumbnail(byteData, 64, 64));
}
else
{
context.Response.BinaryWrite((byte[])dr[1]);
}
context.Response.ContentType = dr[0].ToString();
}
context.Response.Flush();
context.Response.End();
}