Hi!
how to display images in asp.net when i select file upload browse button, that selected image is displayed in control.
which control is used to display images. and also give a code of that process.very urgent sir.
thanku.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amit ChoudharyPosted Feb 11, 2010, 7:31 AM
Following code may help you to upload using Asp.net upload control and show it in a ImageButton control after uploading the image:
protected void btnAddimage_Click(object sender, EventArgs e)
{
string filename = "";
if (FileUpload1.HasFile)
{
try
{
if ((FileUpload1.PostedFile.ContentType == "image/pjpeg") || (FileUpload1.PostedFile.ContentType == "image/jpeg"))
{
filename = FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath("~/ContentImages/Profile/Users/") + filename);
Image1.ImageUrl = "~/ContentImages/Profile/Users/" + filename;
}
}
catch (Exception c)
{
}
}
}
Mark it as answer if it helps.
Amit ChoudharyPosted Feb 15, 2010, 12:39 AM
"~/ContentImages/Profile/Users/" is directory structure i have used in my project
you can say nested directories.
ajay rajuPosted Feb 13, 2010, 2:36 AM
code is not work.
in my image control image is not display. and here what is ("~/ContentImages/Profile/Users/").
plz help me.
thank u.
jitendra kumarPosted Feb 12, 2010, 2:56 AM