私のページでは、私は同じIDを持つ2つの画像を表示しようとしています。そのために、2つのイメージコントロール(imgX、imgY)があります。イメージコントロールにイメージを書き込むには、HttpHandler(ashx)を使用しています。イメージごとにHttpHandler(ashx)を作成する必要はありますか?
imgPhoto.ImageUrl = "Image.ashx?EmpBadge=" & Session("EmpBadge")
imgSign.ImageUrl = "Image.ashx?EmpBadge=" & Session("EmpBadge")
そしてASHXで:
私の問題は、私は両方のコントロール(imgX、imgY)ページのLoadイベントで
に追加同じ画像を取得しています、これは私のコードであるということです
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Try
Dim imageId As String = context.Request.QueryString("EmpBadge")
Dim drPhoto As SqlDataReader
Dim param(1) As SqlParameter
param(1) = New SqlParameter("@EmpBadge", imageId)
drPhoto = IMSIndia.ExecuteReaderWithParam("SpGetPhotoAndSignature", param)
If drPhoto.HasRows Then
While drPhoto.Read()
context.Response.ContentType = "image/" & drPhoto("PhotoType")
context.Response.BinaryWrite(DirectCast(drPhoto("Photo"), Byte()))
context.Response.ContentType = "image/" & drPhoto("Signaturetype")
context.Response.BinaryWrite(DirectCast(drPhoto("Signature"), Byte()))
End While
End If
Catch ex As Exception
Finally
If IMSIndia.con.State = ConnectionState.Open Then
IMSIndia.ConnectionClose()
End If
End Try
End Sub
ありがとうございました。
「imagetype = photo」のような別のクエリー文字列を渡して、単純なif-elseを使って 'ProcessRequest'のコントロールの流れをchnageしないのはなぜですか? – naveen