Answered by:
image thumbnail/enlarge work on ie but not on firefox and chrome

Question
-
User-921158202 posted
hi i have this template field in my gridview
<a href="javascript:void(window.open('<%# "FullImage.ashx?ImID="+ Eval("id_ouvrage")%>','_blank','toolbar=no,menubar=no'))" > <asp:Image ID="Image1" runat="server" ImageUrl='<%# "ThumbNailImage.ashx?ImID="+ Eval("id_ouvrage") %>'/> </a>
fullimage.ashx and ThumbNailImage.ashx retrieve the image from sql server databasethe last ashx apply only some image sizing
here the code :
<%@ WebHandler Language="C#" Class="ThumbNailImage" %> using System; using System.Web; using System.Configuration; using System.Data.SqlClient; using System.Drawing; using System.IO; public class ThumbNailImage : IHttpHandler { public void ProcessRequest (HttpContext context) { string imageid = context.Request.QueryString["ImID"]; if (imageid == null || imageid == "") { //Set a default imageID imageid = "1"; } SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); connection.Open(); SqlCommand command = new SqlCommand("select face from ouvrages where id_ouvrage=" + imageid, connection); SqlDataReader dr = command.ExecuteReader(); dr.Read(); Stream str = new MemoryStream((Byte[])dr[0]); Bitmap loBMP = new Bitmap(str); Bitmap bmpOut = new Bitmap(100, 100); Graphics g = Graphics.FromImage(bmpOut); g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.FillRectangle(Brushes.White, 0, 0, 100, 100); g.DrawImage(loBMP, 0, 0, 100, 100); MemoryStream ms = new MemoryStream(); bmpOut.Save(ms, System.Drawing.Imaging.ImageFormat.Png); byte[] bmpBytes = ms.GetBuffer(); bmpOut.Dispose(); ms.Close(); // byte[] bmpBytes = (byte[])System.ComponentModel.TypeDescriptor.GetConverter(bmpOut).ConvertTo(bmpOut, typeof(byte[])); context.Response.BinaryWrite(bmpBytes); connection.Close(); context.Response.End(); } public bool IsReusable { get { return false; } } }
the problem is this code work perfectely on ie6..8 but not on firefox or chrome
when i click on the thumbnail the popup window show some strange caracters like this :
ÿØÿàJFIFKKÿÛC ÿÛC ÿÀ°Ë"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤
thanks and good day
Sunday, October 18, 2009 7:46 AM
Answers
-
User-1659704165 posted
Hi,
Try defining response content Type Before Straeming..
response.ContentType="image/GIF"
response.ContentType="image/JPEG"
response.ContentType="image/JPEG"- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, October 18, 2009 11:48 AM
All replies
-
User-1659704165 posted
Hi,
Try defining response content Type Before Straeming..
response.ContentType="image/GIF"
response.ContentType="image/JPEG"
response.ContentType="image/JPEG"- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, October 18, 2009 11:48 AM -
User-921158202 posted
thanksSunday, October 18, 2009 11:55 AM