Click here to Skip to main content
15,917,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all.

I am new to ASP.net and learning it. I created a page and put a file upload tool, an image control and a button on page. When I browse an image and click on btn to show that image on that image control, it does not work.

I used the below code in button_click event :

if fileUpload1.HasFile then
imageControl.imageUrl=fileUpload1.PostedFile.FileName
end if


suggest me what should I do.

Thanks.

Gagan
Posted

You need to save the file data to a file on the server, then point the ImageUrl to that path rather than just to the name of the file that was uploaded.
 
Share this answer
 
Thnks for your reply.

Will you please elaborate your answer because I am new to asp.net.

Thanks.

Gagan
 
Share this answer
 
Comments
Christian Graus 2-Sep-10 0:20am    
First of all, don't push answer to ask questions. Second, if you're that new, you should work through a book in sequence, not try to learn stuff at random. Third, the answer is, you have the file bytes on the server, you need to write them to the server, then send the path to the file to the client. You're confused about the server/client difference, and also confused about what an upload control is for. As I said, you should try for more structured learning if you want to understand anything.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



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