Home > .NET Domain Model, ASP.NET > Data Validation in an ASP.NET Web Form

Data Validation in an ASP.NET Web Form


In this previous post we created a few web forms which allowed us to list, create, edit, delete contacts using a CodeFluent Entities generated SQL Server database and object model.

Today, we’re going to use CodeFluent Entities to add a validation rule on our contact’s first name and last name, to ensure no invalid characters can be typed-in (we’re going to use a String validation rule to do that).

By the way, CodeFluent Entities provides the following out-of-the-box validation rules:

  • Compare with another value (<, >, =, <=, >=)
  • String (null, empty, invalid characters),
  • Email (valid email, valid domains),
  • Url (valid url, absolute or relative, valid host name types, valid host names, valid ports, valid schemes)
  • Luhn (valid Luhn code, allow whitespaces),
  • Object (is object, allows null or empty),
  • Regular Expression (specify a regular expression to validate an input),
  • Custom (define your own!)

Since rules are implemented in the Business Object Model, those validation rules will be available in all upper layers, so all your clients whatever they are (ASP.NET, Winforms, WPF, Silverlight, etc.) will benefit from them.

More information on Rules in CodeFluent Entities available here: Documentation.

Check-out the video to see how to declare it in your model and use it in your ASP.NET:

Note: In the video, we’re not using the graphic interface but editing the XML directly.

See you soon for more!

The R&D Team

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s