I have been checking the internet and there is one answer here at *, but it is in vb.net, and I am using c#,
我一直在检查互联网,在*有一个答案,但它是在vb.net,我使用的是c#,
k, this is the deal, I have a binary image stored in a sql server db. I have that working great, to load it in and also to retieve it. In a gridview, I have a link for the detail of the master/detail page. I am using a simple html image tag in the html part here is the code:
k,这是交易,我有一个存储在sql server db中的二进制映像。我有这个很好的工作,加载它,也可以解决它。在gridview中,我有一个主/详细页面详细信息的链接。我在html部分使用一个简单的html图像标签,这里是代码:
I am using VS2010 and C#
我正在使用VS2010和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 have tried many many different ways to format the querystring coming from displayDetail02.aspx, but I can't seam to get the ' and " right to display the paramater, I keep getting '<%' which is the first part of query string.
我的问题是查询字符串变量,我已经尝试了许多不同的方法来格式化来自displayDetail02.aspx的查询字符串,但我无法找到'和'右边显示参数,我不断得到'<%'是查询字符串的第一部分。
I look at it in firebug in mozilla and the querystring is getting passed correctly, but it is not getting processed in the ashx file correctly.
我在mozilla中的firebug中查看它并且查询字符串正确传递,但它没有在ashx文件中正确处理。
I also tried it in the code behind etc, like here is some of the code I have tried.
我也在后面的代码中试过它,就像这里是我尝试过的一些代码。
<% --src='<%# "getLargeImage.ashx?Businessid=" + Eval("Businessid") %>' --%>
It is just one line of code ... oh, I know this works, because when I hardcode a parameter in the ashx (generic handler), I get the image back
这只是一行代码...哦,我知道这有效,因为当我在ashx(通用处理程序)中对参数进行硬编码时,我得到了图像
Could someone please help me?
有人可以帮帮我吗?
3 个解决方案
#1
10
I'm using ashx this way, try to use it as:
我这样使用ashx,尝试使用它:
context.Request.Params["string"]
#2
4
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Img1.Src = "~/getLargeImage.ashx?Businessid=" + Request.QueryString["businessid"];
}
}
#3
0
context.Request.Form["value"]
Where value
is the name that you pass from.
其中value是您传递的名称。
#1
10
I'm using ashx this way, try to use it as:
我这样使用ashx,尝试使用它:
context.Request.Params["string"]
#2
4
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Img1.Src = "~/getLargeImage.ashx?Businessid=" + Request.QueryString["businessid"];
}
}
#3
0
context.Request.Form["value"]
Where value
is the name that you pass from.
其中value是您传递的名称。