Solved

add validation to fileupload .net VB

Posted on 2010-09-18
2
407 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

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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