Tuesday, July 7, 2009

Regular Expression Restricting the type of file to Upload

I was working on the file upload control yesterday, and I wanted to restrict the users to be able to upload only html files.

Here's the html that will take care of that:


<asp:RegularExpressionValidator id="RegularExpressionValidator1"
ControlToValidate="flUpload"
ValidationExpression=".*([.]html)$"
Display="Dynamic"
ErrorMessage="Only Html Uploads Allowed"
EnableClientScript="True"
runat="server"/>


Oh, and by the way, I found out how to retain the color coding of the html/codebehind text! Yay!

No comments: