Solved

add validation to fileupload .net VB

Posted on 2010-09-18
2
405 Views
Last Modified: 2012-06-27
Right now my FileUpload is being validated to check for the correct file extension, but I would also like to make sure that the field is not empty. How would I modify the below code to make sure that the field cannot be left empty? Thanks.

<asp:RegularExpressionValidator id="FileUpLoadValidator2" runat="server" ErrorMessage="    Upload .png files only."
ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.png|.PNG|.png|.PNG)$"
ControlToValidate="FileUpload1">
</asp:RegularExpressionValidator>
0
Comment
Question by:elliottbenzle
2 Comments
 
LVL 22

Accepted Solution

by:
Om Prakash earned 500 total points
ID: 33707213
add required field validator

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
	            ControlToValidate="FileUpload1" ErrorMessage="File Required!">
        </asp:RequiredFieldValidator>
        <asp:RegularExpressionValidator id="FileUpLoadValidator2" runat="server" ErrorMessage="    Upload .png files only."
	ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.png|.PNG|.png|.PNG)$"
	ControlToValidate="FileUpload1">
</asp:RegularExpressionValidator> 

Open in new window

0
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 33709967
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question