Tags: datingsitesdatingsites infodating service for married man 20Yuvutu camFree chat sex core teenFreecyberchatmacedonian single ladies datingSex dateingSexy free camera telefonOpen sex chat wiyhout loginnco dating officer
This is the second in a series of blog posts I’m doing on the upcoming ASP. This blog post covers some of the validation improvements coming with ASP. Validating user-input and enforcing business rules/logic is a core requirement of most web applications. NET MVC 2 includes a bunch of new features that make validating user input and enforcing validation logic on models/viewmodels significantly easier.
We’ll choose to scaffold a “Create” view that is passed a Person object: Visual Studio will then generate a scaffolded view file for us under the \Views\Friends\ directory of our project.
Notice below how it takes advantage of the new strongly-typed HTML helpers in ASP.
This ability to specify the validation rules one place and have it be honored and respected everywhere allows us to rapidly evolve our application and rules with a minimum amount of effort and keep our code very DRY.
Our application currently only performs server-side validation – which means that our end users will need to perform a form submit to the server before they’ll see any validation error messages. NET MVC 2’s validation architecture is that it supports both server-side client-side validation.
As part of this process, it will also check to see whether the Data Annotation validation attributes for the Person object are valid. Is Valid check within our code will return true – in which case we will (eventually) save the Person to a database and then redirect back to the home-page.
If there are any validation errors on the Person object, though, our action method redisplays the form with the invalid Person.
NET MVC 2 (enabling better intellisense and compile time checking support): And now when we run the application and hit the URL we’ll get a blank form that we can enter data into: Because we have not implemented any validation within the application, though, nothing prevents us from entering bogus input within the form and posting it to the server.
Let’s now update our application to enforce some basic input validation rules.
We also want to ensure that our code maintains the DRY principle (“don’t repeat yourself”) – meaning that we should only apply the validation rules in one place, and then have all our controllers, actions and views honor it.
Below I’m going to be using VS 2010 to implement the above scenario using ASP. You could also implement the exact same scenario using VS 2008 and ASP. We’ll begin by adding a simple “Person” class to a new ASP.