Archive, ASP.NET

Validating Drop Downs In ASP.NET – Part 2

In part 1 of Validating Drop Downs In ASP.NET we discussed how to use the Required Field Validator to provide responsive client side validation of form controls without directly writing JavaScript. In this post we are going to discuss how to allow postbacks without validating form controls.

While that sounds contradictory to the goal of validation I assure you it is not. Consider our scenario from last time:

	--please select one--

In addition to allow your site users to select either apples or oranges you also have a submit button to send their result back to the server.

So far everything is working just fine. You users can select a fruit and send their choice to the web server for processing. But what if you need a cancel button that also needs to postback to the server?

This is where the CausesValidation button property comes in.

By default all buttons CausesValidation property is true, so by changing it to false we can all only specific buttons to postback without the form controls necessarily validating.

Allowing the form to postback without validation is as simple as adding the CausesValidation=”false” property to each button that needs to circumvent validation.

Never miss an article! Subscribe to my newsletter and I'll keep you updated with the latest content.


About Jason

Jason is an experienced entrepreneur & software developer skilled in leadership, mobile development, data synchronization, and SaaS architecture. He earned his Bachelor of Science (B.S.) in Computer Science from Arkansas State University.
View all posts by Jason →

Leave a Reply

Your email address will not be published. Required fields are marked *