Set 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="fileUploadSri" 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,
fileUploadSri.Attributes.Add("onkeypress", "return false;");
fileUploadSri.Attributes.Add("onkeyup", "return false;");
fileUploadSri.Attributes.Add("onpaste", "return false;");

Comments

Popular posts from this blog

ASP.NET Compillation Error BC31007 - Solution

The Difference between GET and POST

Test & Debug WCF service using WCFTestClient.exe