CODEDIGEST
Home » CodeDigest
Search
 

Technologies
 

How to make FileUpload control in ASP.Net 2.0 to Read-Only?
Submitted By Satheesh Babu B
On 12/26/2008 9:00:42 AM
Tags: ASP.Net,ASP.Net 2.0,CodeDigest  

How to make FileUpload control in ASP.Net 2.0 to Read-Only?

 

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

<asp:FileUpload ID="fuFile" 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,

 

        fuFile.Attributes.Add("onkeypress", "return false;");

        fuFile.Attributes.Add("onkeyup", "return false;");

        fuFile.Attributes.Add("onpaste", "return false;");

Do you have a working code that can be used by anyone? Submit it here. It may help someone in the community!!

Recent Codes
  • View All Codes..