Click here to Skip to main content
15,900,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i am storing path in database its stores in D:\OrgWebsite\Traditional Day 2012\Images\DSC01049.JPG format.

but at time of retrieving if i use image button
<asp:ImageButton ID="ImageButton1" runat="server" CommandArgument='<%#Eval("a_id") %>' ImageUrl='<%#Eval("i_path") %>' Height="100" Width="100" />

it shows me this "D:\\OrgWebsite\\Traditional Day 2012\\Images\\DSC01049.JPG" format.

so i am unable to view images.
Can u help?
Posted
Updated 20-Jan-14 0:30am
v2
Comments
Kornfeld Eliyahu Peter 20-Jan-14 6:41am    
The double slash (\\) is not your problem for sure...
Probably you should convert the path from absolute to relative and map to the web site's directory...
But! Let us see the error (client or server), so the answer should more specific...

You have to save your file at that folder by writing this code :

C#
if (FileUpload1.HasFile == true)
        {
            
         //Code to save image in folder
            FileUpload1.SaveAs(Server.MapPath("~/Traditional Day 2012/Images/" + FileUpload1.FileName));


         //Code to save image url in database
            string ImageUrl = "~/Traditional Day 2012/Images/" + FileUpload1.FileName;

        }


And then You just have to bind that url in your ImageButton Control....
 
Share this answer
 
v2
Comments
Nirav Prabtani 20-Jan-14 8:31am    
are waah...sachu ho bhai.. :)
while saving in the database you should save only "Images\DSC01049.JPG"
i hope Images will be in the root directory..
Images should be in the hosted directory only.. not apart from that...
Try this. it should work...
 
Share this answer
 
Comments
sumit kausalye 20-Jan-14 7:21am    
no sir folders are created dynamically so root directory is not fixed
Karthik_Mahalingam 20-Jan-14 7:56am    
folders are created dynamically inside your hosted server directory or someother drive ?

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