Hi guys, does anybody use FancyBox JQuery popup here?
I encounter a weird problem when I combine Handler (.ashx) and FancyBox to display image. The image render correctly on the webpage, but not inside of the FancyBox JQuery popup.
Here is my code for the Handler (.ashx), is there anything wrong with it?
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data.SqlClient;
using System.Configuration;
namespace cK
{
///
/// Summary description for $codebehindclassname$
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class GetImage : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
HttpContext.Current.Response.ContentType = "image/jpeg";
HttpContext.Current.Response.WriteFile("test123.jpg");
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
NYCharles
Member
377 Points
95 Posts
Image Handler - image rendering problem in FancyBox JQuery popup
Aug 03, 2009 06:55 PM|LINK
Hi guys, does anybody use FancyBox JQuery popup here?
I encounter a weird problem when I combine Handler (.ashx) and FancyBox to display image. The image render correctly on the webpage, but not inside of the FancyBox JQuery popup.
Here is my code for the Handler (.ashx), is there anything wrong with it?
using System; using System.Data; using System.Web; using System.Collections; using System.Web.Services; using System.Web.Services.Protocols; using System.Data.SqlClient; using System.Configuration; namespace cK { /// /// Summary description for $codebehindclassname$ /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class GetImage : IHttpHandler { public void ProcessRequest(HttpContext context) { HttpContext.Current.Response.ContentType = "image/jpeg"; HttpContext.Current.Response.WriteFile("test123.jpg"); } public bool IsReusable { get { return false; } } } }vfarmak
Member
29 Points
19 Posts
Re: Image Handler - image rendering problem in FancyBox JQuery popup
Oct 07, 2009 09:59 AM|LINK
In order to use fancy box and jquery with asp.net, you have to display the image in a dummy aspx webpage.
The dummy aspx web page must have an <asp:Image> server control, in which the ImageUrl Property must have the url of your ImageHandler.
For example:
<asp:Image ID="myImage" runat="server" ImageUrl="ImageHandler.ashx"/>
NYCharles
Member
377 Points
95 Posts
Re: Image Handler - image rendering problem in FancyBox JQuery popup
Oct 07, 2009 01:10 PM|LINK
I fixed this problem. It seems the Fancy Box jQuery was looking for the file extension in order to present the content.
Now my image source link is "ImageHandler.ashx?file=sky.jpg"
Originally I had "ImageHandler.ashx?fileID=2", that is why it is giving me ASCII text instead of an image.
mynickname
Member
66 Points
93 Posts
Re: Image Handler - image rendering problem in FancyBox JQuery popup
Dec 04, 2011 10:05 PM|LINK
Could you please show more form your handler? I have the same problem :(