tags:

views:

286

answers:

2

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 there 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!

A: 

Try resolving the url before assigning it to the image.

imgbtnImage.ImageUrl = ResolveUrl(sb.ToString)
Joel Potter
+1  A: 

This may be your problem:

ImageUrl='<%# "~\Handlers\ImageHandler.ashx?id=" & Eval("ID") %>'
ChaosPandion
+1, nice guess; maybe OP also want to add some UrlEncode stuff
Rubens Farias
The OP said the second block of code was failing, not the first block. I think the missing characters were just a typo.
Joel Potter