Solved

How to do Page Validation?

Posted on 2004-08-31
2
173 Views
Last Modified: 2010-04-23
Hi Experts!

I think this is a fairly simple question but I am not sure of the best way to do it.  I have required field and expression validators on all of my user input text boxes on a form.  The validators fire upon clicking a SUBMIT button which has "causes validation"  set to true.  I currently display a * next to any required field that was missed by using the required field validators but I would also like to display a label or message box if any of the validators fire that tells the user to re-check the form for missed fields.

my thoughts were something like this:

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        If Page.IsValid Then
'Insert data
else
lblError.visible = true
end Sub

I may not understand the correct way to use Page.IsValid or if anyone has a better way to do this please let me know..
Thanks!!
0
Comment
Question by:jcraun
2 Comments
 
LVL 8

Accepted Solution

by:
thrill_house earned 200 total points
ID: 11945056
You can actually do it rather easy by adding a Validation Summary control.

Just add this to your html side: <asp:ValidationSummary id="ValidationSummary1" runat="server" ShowSummary="False" ShowMessageBox="True"></asp:ValidationSummary>

Now the error messages will show up in a message box as well as put the * next to the problem.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

12 Experts available now in Live!

Get 1:1 Help Now