Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

add validation to fileupload .net VB

Posted on 2010-09-18
2
Medium Priority
?
414 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
Om Prakash earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

609 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