Search This Blog

Friday, January 28, 2011

FileUpload Control

Disable pasting and typing of text in FileUpload Control
<asp:FileUpload ID="FileUpload1" runat="server"
onkeydown = "return (event.keyCode==9);"
onpaste = "return false;" />
When you add the two events to aspx page directly Visual Studio produces warning which is not an issue to worry since these are client side events and Visual Studio checks for Server Side events still if you do not want that to happen you can add the same from code behind too in the following way

FileUpload1.Attributes.Add("onkeydown", "return (event.keyCode==9);");

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

No comments:

Post a Comment