Click here to Skip to main content
15,891,184 members

Retrieve more than one image on a page along with other contents using http handler (ashx)

6,921,364 and growing asked:

Open original thread
Hi everyone,

Let me explain the scenario.

I have to display a page which will show user's personal information along with his profile picture and signature (after log-in).
The profile picture and signature are stored in database.
I am using 2 Image control on the web page. I am retrieving the image using http handler.
XML
<asp:Image ID="imgUserImage" runat="server" AlternateText="User Photo" Height="130px" Width="150px" />
<br /> <asp:Image ID="imgUserSign" runat="server" AlternateText="User Signature"
Height="40px" Width="150px" />


Now the user id will be obtained at runtime. So I am assigning the url to the image at runtime like this:
C#
//show user image
imgUserImage.ImageUrl = "showUserImage.ashx?imgtype=photo&id=" + empid;
//show user signature
imgUserImage.ImageUrl = "showUserImage.ashx?imgtype=sig&id=" + empid;


Based on the imgtype querystring, the handler is processing the request and will display corresponding image.

Now the problem is, the ProcessRequest method is called only once (after Page_Load of aspx) which I think is correct.
Is there a way I can show both the images on the page using the handler.
I couldn't find a solution on the web. :(

Thanks!
Tags: ASP.NET, Image

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900