Solved

add validation to fileupload .net VB

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now