Click here to Skip to main content
15,896,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using image component of visual studio. I want to display the image in asp.net page when user runs the code.. the name of the image is stored in database and based on the name, the image is to be displayed from given location. I have tried the following code but it is not working..

at aspx
<asp:Image ID="ImgUpload" runat="server" />

at aspx.cs
ImgUpload.ImageUrl = MapPath(@"~/Photo/" + photo);

where photo gives the name of image. Any help...
Posted
Comments
Thomas ktg 26-Sep-13 5:47am    
make sure the imageurl is valid from MapPath.
Thanks7872 26-Sep-13 5:55am    
Try using

ImgUpload.ImageUrl = "~/Photo/" + photo;


or

ImgUpload.ImageUrl = HttpContext.Current.Server.MapPath("/photo.....");
Codes DeCodes 26-Sep-13 6:06am    
thank u Rohan.. it worked.

1 solution

yes it is valid.. I have inserted breakpoint and checked for it by taking the imageurl into browser.
 
Share this answer
 

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