Validating file extension with regularexpressionvalidator

21 Nov

Now you can ask questions directly to me on my new site ASPForums. Net Question Answer site, specially started to allow visitors of this site ask their doubts and queries. Just click the Ask Now button and ask your question now.It will automatically validate the extension of the uploaded file before the page is posted back.

If you rely on the name, it's a huge security flaw. :pattern) = match the pattern without storing the match) [d D] = any character in the set ('d' or 'D') [x X]?

You can leave out the ^.* as "match anything from the beginning up until this expression at the end" is the same as "match this expression at the end". i:)" just matches nothing, case-insensitively.^ = beginning of string .

You can also embed regular expression options msdn.microsoft.com/en-us/library/yd1In order to embed the regular expression option to ignore case you need to disable Client Side script (I don't think Java Script support it). i:.(jpg|gif|doc|pdf))$" for a case insensitive match. Then, when you call Is Match() make sure to pass Regex Options. There is no reason to have to list out the variations for casing.

The expression for video formats is: Now, run the application and see the output.

When you upload an invalid file it will immediately give the validation error message indicating an invalid file format.