I am checking the internet and there is one answer here on stackoverflow, but it is on vb.net and I am using C #,
k, this is a deal, I have a binary image stored in db sql server. It works fine for me to download it, as well as cancel it. In gridview, I have a link to the detail of the main / detail page. I use a simple html image tag in the html part, here is the code:
I am using VS2010 and C #
(displayDetail02.aspx)
<body> <form id="form1" runat="server"> <div> <img id="Img1" width="500" runat="server" src="~/getLargeImage.ashx?Businessid=<%Eval(businessid)%>" alt="Business Image" style="border: 1px inset"/> </div> </form> </body>
Here is the code behind:
public partial class displayDetail02 : System.Web.UI.Page { public string businessid = string.Empty; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { businessid = Request.QueryString["businessid"]; } } }
(getLargeImage.ashx)
public partial class getLargeImage : IHttpHandler { public void ProcessRequest(HttpContext context) { HttpContext _context = HttpContext.Current; context.Response.ContentType = "image/jpg"; string businessid = Convert.ToString(context.Request.QueryString["businessid"]); ...
My problem is the querystring variable, I tried many different ways to format the request received from displayDetail02.aspx, but I canโt seam to get โandโ the right to display the parameter, I continue to get '<%', which is the first part of the line request.
I look at it in firebug in mozilla and the request is executed correctly, but it is not being processed correctly in the ashx file.
I also tried it in the code behind, etc., for example, here are some of the code I tried.
<% --src='<%# "getLargeImage.ashx?Businessid=" + Eval("Businessid") %>' --%>
This is just one line of code ... oh, I know this works, because when I hardcode a parameter in ashx (generic handler), I get the image back
Can anyone help me out?