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

x
?
Solved

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

Posted on 2012-03-29
3
Medium Priority
?
467 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
[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
3 Comments
 
LVL 4

Assisted Solution

by:Victor Tarasov
Victor Tarasov earned 400 total points
ID: 37782739
Use Page.IsValid
Read
0
 
LVL 9

Assisted Solution

by:TonyReba
TonyReba earned 400 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 1200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

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