Thursday, April 23, 2009

RegularExpressionValidator for image upload

Hi all,

you can control for uploading of only images(.jpg,.gif) etc.
Using the RegularExpressionValidator you can validate it on client side .
Here is the code for this :

asp:regularexpressionvalidator runat="server" errormessage="Only picture files are allowed!" validationexpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.gif|.GIF|.jpg|.JPG|.jpeg|.JPEG)$" controltovalidate="fileUpload" display="None">

http://forums.asp.net/p/1411282/3093528.aspx#3093528

No comments:

Post a Comment