Solved

How to determine if asp.net validate control has reported an error?

Posted on 2012-03-29
3
460 Views
Last Modified: 2012-03-31
I have a basic ASP.NET C# web application.  Each control is paired with a validator control and the errors are displayed to the user via "validation summary" control. The Web page has a next button to go to another aspx page.  How do I check in the code behind the Next button if errors exist and not go to the next page?
MSDN shows the ValidatorSummary has a "HasErrors" property.  However, this is not a valid property.

on NEXT button
if no errors go to next page
otherwise redisplay the current page.

thanks
0
Comment
Question by:wilfordrocks
3 Comments
 
LVL 4

Assisted Solution

by:VictorTarasov
VictorTarasov earned 100 total points
ID: 37782739
Use Page.IsValid
Read
0
 
LVL 9

Assisted Solution

by:TonyReba
TonyReba earned 100 total points
ID: 37783526
Well , if you are using the asp validation controls, it should not go to next page, unless you the validation arguments are valid....



As Victor Suggested you can also do;

   protected void btnSubmit_Click(object sender, EventArgs e)
    {
        // If Page is Valid          
        if (Page.IsValid )
        {  

            // Redirect Page 2

           Response.Redirect("Page2.aspx");
        }

    }
0
 
LVL 7

Accepted Solution

by:
Lalit Chandra earned 300 total points
ID: 37784207
ASP.NET 2.0 validator control render a javascript file in which there is a function
ValidatorValidate(validatorcontrolid).
It is this function that actualy gets fired for each validator control on the clientside.
So, on the client side i.e in javascript you can explicitly call this function to validate forcely.
And at the server side, you have to use
Page.IsValid property as suggested by VictorTarasov.

Hope this will make you clear idea about the asp.net Validation at client side.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dot Net 4.6.1 installation fails on W2012 R2 server 14 38
Help with error in Query 2 31
C# MVC Insert Multiple Row into DB 2 30
Change to file doesn't show up 16 51
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

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