Asp.Net File Upload Validation

RegularExpression For File upload Control


 <asp:FileUpload ID="flUpload" runat="server" />
 <asp:RequiredFieldValidator ID="rfvFileUpload" ControlToValidate="flUpload" runat="server"  ErrorMessage="Please select File."></asp:RequiredFieldValidator>
 <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="flUpload"
                            ErrorMessage="Only .jpg,.png,.jpeg,.gif Files are allowed" Font-Bold="True" Font-Size="Medium"
                            ValidationExpression="(.*?)\.(jpg|jpeg|png|gif|JPG|JPEG|PNG|GIF)$" Width="360px"></asp:RegularExpressionValidator>

File Upload

Advertisement

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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