ASP.NET File Upload Control - Force the user to browse
The File Upload Control is used to let users upload local files to the server. There are two (2) ways to set the filename on this control ,
- By clicking the “Browse” button, and
- Manually type the filename on the textbox.
Option 1 ensures that the value set on the control exists and valid while Option 2 could not guarantee this since they maybe able to type an incorrect filename/filepath.
So how do you get a workaround on this issue?
Simply add the following code on the PageLoad event,
FileUpload1.Attributes.Add(”onkeydown”, “return false;”);
