0

I use the FileUpload control to upload files to remote hosting server in C# ASPNET.

I have restrict the FileUpload control to upload a file type.

For example, I wanted to upload text file (txt) only so I put a validator, which allows txt only.

<asp:RegularExpressionValidator   
id="FileUpLoadValidator" runat="server"   
ErrorMessage="Upload Text file only."   
ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.txt)$"   
ControlToValidate="FileUpload1">  
</asp:RegularExpressionValidator> 

The typical Open File Dialog looks like figure below where you can see Windows Explorer like features to navigate through folders and select a file.

enter image description here

how to do when the browse button click event handler will show an open file dialog and users will be able to select only text files?

enter image description here

0 Answers0