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

How to assign default value to fileupload control in code view in asp.net with c#.

There is an image path in database. I want show that path in FileUpload text at the time of retrieval.

Bye
Posted
Updated 6-Nov-11 19:05pm
v2

 
Share this answer
 
As per my knowledge you can not. Sorry but thats how FileUpload control is. It expects Users to select File using it's "Browse" button.

However you may try to find out work around for this on Google if their is any.

Google Search Result
 
Share this answer
 
v3
due to browser security, this is prevented.

Check this
http://forums.asp.net/t/1435276.aspx[^]
 
Share this answer
 
Simple answer is you can't. Because security reasons.
 
Share this answer
 
C#
if(FileUpload1.HasFile)
{
  FileUpload1.SaveAs(Server.MapPath("images/" +  FileName));
}
else
{
//Code for default
}
 
Share this answer
 
Comments
purnananda behera 7-Nov-11 0:44am    
Actually i was not aspecting this.
There is an image path in database. I want show that path in FileUpload text at the time of retrieval. Is it possible or not.
Prerak Patel 7-Nov-11 2:01am    
No, you should use label for that.

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