ASP.NET - Not able to display Image from one to another page

Asked By Dikshan Shah on 12-Sep-12 06:52 AM
Rolf Jaeger replied to Dikshan Shah on 12-Sep-12 10:42 AM
What have you tried so far?
Dikshan Shah replied to Dikshan Shah on 12-Sep-12 10:35 PM
There is a Fileupload control on my registration page and that filename i want on next page and so i can display with Image control.
couldn't work easily....
suggest me some code for it..
Jitendra Faye replied to Dikshan Shah on 13-Sep-12 01:15 AM
For Retrieving image from database and displaying, you can use Handler.

use following code-

step1 :

protected void Page_Load(object sender, EventArgs e)
Image1.ImageUrl = "handler1.ashx?EmpID='1'";

step2:   handler code

public void ProcessRequest(HttpContext context)
SqlConnection cn = new SqlConnection("YOUR CONNECTION STRING");
string empid = context.Request.QueryString["EmpID"].ToString();
SqlCommand cmd = new SqlCommand("select empimage from empimageTABLE where empid=" + empid, cn);
SqlDataReader dr = cmd.ExecuteReader();

try this code and let me know.