Solved

add validation to fileupload .net VB

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

Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

690 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