Asp Fileupload Control Allow only image files

25 Nov

alowing only image in file control you can use the following RegularExpressionValidator

<asp:FileUpload ID = “fuBannerImage” runat =”server” Width=”280px” style=”color:#999″ />


<asp:RegularExpressionValidator ID=”RegularExpressionValidator1″ runat=”server” ErrorMessage=”Only picture allowed!” ValidationExpression=”^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.png|.bmp|.gif|.GIF|.jpg|.JPG|.jpeg|.JPEG)$” ControlToValidate=”fuBannerImage” Display=”Dynamic”></asp:RegularExpressionValidator>


Leave a comment

Posted by on November 25, 2012 in ASP Dot Net C#



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: