Click here to Skip to main content
15,907,001 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want my File upload control as read only, so that no one can edit file upload text box. However I could select file using browse button. Write code
Posted
Comments
Smithers-Jones 7-Nov-11 6:43am    
Is that an order???

Use like this

ASP.NET
<asp:fileupload id="FileUpload1" runat="server" onkeydown="javascript:return false;" xmlns:asp="#unknown" />
 
Share this answer
 
 
Share this answer
 
Try this

We can make the ASP.Net FileUpload control readonly by setting the ContentEditable property to false.

C#
<asp:FileUpload ID = "fileUpload1" ContentEditable="false" runat="server" />


The other way of achieving it by restricting users to type in any characters i.e. return false on key press, key up and on paste event to prevent users pasting any values directly.

Refer the below code snippet that helps in doing that,

C#
fileUpload1.Attributes.Add("onkeypress", "return false;");
fileUpload1.Attributes.Add("onkeyup", "return false;");
fileUpload1.Attributes.Add("onpaste", "return false;");


Hope this helps!!

Refer these:

http://codes.codedigest.com/CodeDigest/69-How-to-make-FileUpload-control-in-ASP-Net-2-0-to-Read-Only-.aspx[^]

http://basgun.wordpress.com/2008/01/28/aspnet-fileupload-readonly/[^]

http://forums.asp.net/t/1325942.aspx/1[^]
 
Share this answer
 
v4

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