Passing an id though the querystring to an httphanlder was not so hard in a bindable control like a gridview. I put an imagebutton in the gridview and set its Imageurl Property as such....
ImageUrl='<%#"~\Handlers\ImageHandler.ashx?id=" & Eval("ID")
However, now I am trying to just use a standard Imagebutton control just sitting ther开发者_开发问答e on a user control. I call this method I created on the user control:
Public Sub LoadImage()
Dim sb As New StringBuilder
sb.Append("~\Handlers\ImageHandler.ashx")
sb.Append("?imageSourceCode=" & _imageSourceCode.ToString)
sb.Append("&displayTypeCode=" & _displayTypeCode.ToString)
sb.Append("&imageData=" & _imageData.ToString)
imgbtnImage.ImageUrl = sb.ToString
End Sub
...in an attempt to pass some paramters into the httphandler, but once inside, it doesn't see them. The I noticed I had also harded an ImageUrl property on the imagecontrol itself to point to the handler w/o querystring. So, I deleted that and now it fails completely!
This may be your problem:
ImageUrl='<%# "~\Handlers\ImageHandler.ashx?id=" & Eval("ID") %>'
Try resolving the url before assigning it to the image.
imgbtnImage.ImageUrl = ResolveUrl(sb.ToString)
精彩评论