SlideShare une entreprise Scribd logo
1  sur  9
Télécharger pour lire hors ligne
Validation Process Using Data Annotation In ASP .NET MVC
What are Data Annotations?
Data annotations define the list of attribute classes that can be found in System. ComponentModel.
DataAnnotations namespace to apply to classes and properties to enable various pre-defined
validation rules. You can easily work with these annotations by obtaining them from various Visual
Studio 2010 project versions, including ASP.NET MVC, Web Forms, ASP.NET Apps & Web Sites,
Dynamic Data & non ASP.NET projects such as Silverlight and WPF. So, for data models also, one
can easily use these annotations with POCOs feature that is commonly pronounced as plain old
CLR objects, EF models and Linq2SQL models. But if we talk universally, data annotations can be
used anywhere.
You will come across various box annotations such as:
 Required
 Regular Expression
 Range
 ZipCode
 DisplayName
 DisplayFormat
 Scaffold
 DataType
 StringLength
There are various ASP.NET Development company who posses ample of expertise and high
proficiency skills in ASP.NET Development sector. But to be one of the most renowned ASP.NET
development company, it's necessary for every employer to focus on hiring an eventually
sound.NET developer who will bring out the maximum and best output to you.
Some of our areas of .NET expertise includes:
 High performance application architectures
 Stringent Coding practices
 Ease of Maintenance systems
 Cost Effective Delivery Modes
# How to work with Data Annotation Validator Attributes
At the time of working with Data Annotations Model Binder, we need validator attributes to
perform such validation process in ASP.NET MVC. You need to add
System.ComponentModel.DataAnnotations namespace that comprises of following validator
attributes:
Range – validates the property value that falls within a specific range of values.
ReqularExpression – verifies property value to match a specified regular expression pattern.
Required – Allows us to mark a property as per the requirement.
StringLength – Lets you specify a maximum length for your string property.
Validation – Defines a base class for all validator attributes.
The Employee class in Listing 1 guides how to use this validator feature. The Name, AboutMe,
and Salary properties are marked as per requirements are concerned. The Name property should
consist a string length that should be less than fifty characters. The Salary property should properly
match the Regular Expression pattern to represent a employe's salary properly.
using System.ComponentModel.DataAnnotations;
namespace MvcApplication.Model
{
public class Employee
{
public int EmployeeId { get; set; }
[Required]
[StringLength(30)]
public string Name { get; set; }
[Required]
public string AboutMe { get; set; }
[Display(Name = "Employee Salary")]
[Required]
[RegularExpression(@"^$?d+(.(d{2}))?$",ErrorMessage="Employee
Salary must be a decimal value")]
public decimal Salary { get; set; }
}
}
# List 1:
The Employee class deals with coding guides, user about how to use additional attribute: the
Display attribute. The Display attributes allows you to modify the property name at the time
property is displayed as an error message. Employee class in Listing 1 with Create () controller
action feature in Listing 2 can easily be used together. This controller action will again display the
Create view property at the time when a model state will contain errors.
using System.Web.Mvc;
using MvcApplication.Models;
namespace MvcApplication.Controllers
{
public class EmployeeController : Controller
{
//
// GET: /Employee/Create
public ActionResult Create()
{
return View();
}
//
// POST: /Employee/Create
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create([Bind(Exclude = "EmployeeId")]Employee
employeModel)
{
if (!ModelState.IsValid)
return View();
// TODO: Add insert logic here
return RedirectToAction("Index");
}
}
}
# List 2: ControllersEmployeeController.cs
Create the view feature in Listing 3 by simply right-clicking on Create() action and then select the
menu option known as Add View. Create a view with the Employee class as a model class. Again
select Create option from the view content dropdown list.
@model MvcApplication.Models.Employee
@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Create</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Employee</h4>
<hr />
@Html.ValidationSummary(true)
<div class="form-group">
@Html.LabelFor(model => model.Name, new { @class = "control-label
col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.AboutMe, new { @class = "control-
label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.AboutMe)
@Html.ValidationMessageFor(model => model.AboutMe)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Salary, new { @class = "control-label
col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Salary)
@Html.ValidationMessageFor(model => model.Salary)
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
# List 3: ViewsEmployeeCreate.cshtml
At the time of submitting a form to create any Employee, if you do not enter the specific values
for all the required fields, then the validation error messages in Figure 3 will be displayed.
If you enter an invalid value in Salary, then the error message in Figure 4 is displayed.
# Steps To Work With Data Annotation Validators with the Entity Framework
If you are working with the Microsoft Entity Framework to validate a data model class, then it's not
possible to apply validator attributes directly to classes. The reason behind this: Entity Framework
Designer generates various model classes, and any modifications that are made to the model class
will be overwritten next time if you come across with any changes in the Designer.
To use validators with classes that are generated by the Entity Framework with ASP.NET MVC,
then it's necessary to create metadata classes first. Apply validates to your metadata class.
# Figure 5: State class generated by Entity Framework
using System.ComponentModel.DataAnnotations;
namespace MvcApplication.Model
{
[MetadataType(typeof(StateMetaData))]
public partial class State
{
}
public class StateMetaData
{
[Required]
[Display(Name="State Name")]
public object StateName { get; set; }
}
}
# Listing 4: ModelsState.cs
The file in Listing 4 comprises of two classes that are known as State class and
StateMetaData class. Here State class is a partial class that easily corresponds to the partial
class at the time time it is generated by Entity Framework, contained in the DataModel.Designer.vb
file.
Note: But currently .NET framework does not support partial properties.
Here State partial class is developed with MetadataType attribute that signifies the
StateMetaData class. StateMetaData class comes with proxy setting properties for State
class property.
The page in Figure 6 illustrates the error messages returned when you enter invalid values for the
State properties.
# Figure 6: Using validators with the Entity Framework
To work with ASP.NET MVC Data Annotations, it is necessary to hire a highly experienced
Asp .NET Developer who possesses high.NET coding skills.
# Qualities of a good .NET Developers :-
 Experienced and qualified professionals
 Strong technical knowledge
 Proven methodologies
 Effective communication
 Thorough technical expertise
 Fast turnaround time
 Committed to deliver ASP.NET development services to match client's expectaions
 Analytical Approach towards programming

Contenu connexe

En vedette

Mary Edwards - The Big Thaw - Isle of Wight Cafe Sci, Oct 2016
Mary Edwards - The Big Thaw - Isle of Wight Cafe Sci, Oct 2016Mary Edwards - The Big Thaw - Isle of Wight Cafe Sci, Oct 2016
Mary Edwards - The Big Thaw - Isle of Wight Cafe Sci, Oct 2016Simon Perry
 
Comment partager sur LinkedIn
Comment partager sur LinkedInComment partager sur LinkedIn
Comment partager sur LinkedInNathalie Agbagla
 
Catalogo incefra lancamentos
Catalogo incefra lancamentosCatalogo incefra lancamentos
Catalogo incefra lancamentoshmalta
 

En vedette (6)

Каталог лето 2016
Каталог лето 2016Каталог лето 2016
Каталог лето 2016
 
Mary Edwards - The Big Thaw - Isle of Wight Cafe Sci, Oct 2016
Mary Edwards - The Big Thaw - Isle of Wight Cafe Sci, Oct 2016Mary Edwards - The Big Thaw - Isle of Wight Cafe Sci, Oct 2016
Mary Edwards - The Big Thaw - Isle of Wight Cafe Sci, Oct 2016
 
Comment partager sur LinkedIn
Comment partager sur LinkedInComment partager sur LinkedIn
Comment partager sur LinkedIn
 
SVP Lesson
SVP LessonSVP Lesson
SVP Lesson
 
CV - Adamu Bulama
CV  - Adamu BulamaCV  - Adamu Bulama
CV - Adamu Bulama
 
Catalogo incefra lancamentos
Catalogo incefra lancamentosCatalogo incefra lancamentos
Catalogo incefra lancamentos
 

Dernier

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Dernier (20)

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Asp .Net MVC Validation process using Data Annotation

  • 1. Validation Process Using Data Annotation In ASP .NET MVC What are Data Annotations? Data annotations define the list of attribute classes that can be found in System. ComponentModel. DataAnnotations namespace to apply to classes and properties to enable various pre-defined validation rules. You can easily work with these annotations by obtaining them from various Visual Studio 2010 project versions, including ASP.NET MVC, Web Forms, ASP.NET Apps & Web Sites, Dynamic Data & non ASP.NET projects such as Silverlight and WPF. So, for data models also, one can easily use these annotations with POCOs feature that is commonly pronounced as plain old CLR objects, EF models and Linq2SQL models. But if we talk universally, data annotations can be used anywhere. You will come across various box annotations such as:  Required  Regular Expression  Range  ZipCode  DisplayName  DisplayFormat  Scaffold  DataType  StringLength There are various ASP.NET Development company who posses ample of expertise and high proficiency skills in ASP.NET Development sector. But to be one of the most renowned ASP.NET development company, it's necessary for every employer to focus on hiring an eventually sound.NET developer who will bring out the maximum and best output to you.
  • 2. Some of our areas of .NET expertise includes:  High performance application architectures  Stringent Coding practices  Ease of Maintenance systems  Cost Effective Delivery Modes # How to work with Data Annotation Validator Attributes At the time of working with Data Annotations Model Binder, we need validator attributes to perform such validation process in ASP.NET MVC. You need to add System.ComponentModel.DataAnnotations namespace that comprises of following validator attributes: Range – validates the property value that falls within a specific range of values. ReqularExpression – verifies property value to match a specified regular expression pattern. Required – Allows us to mark a property as per the requirement. StringLength – Lets you specify a maximum length for your string property. Validation – Defines a base class for all validator attributes. The Employee class in Listing 1 guides how to use this validator feature. The Name, AboutMe, and Salary properties are marked as per requirements are concerned. The Name property should consist a string length that should be less than fifty characters. The Salary property should properly match the Regular Expression pattern to represent a employe's salary properly. using System.ComponentModel.DataAnnotations; namespace MvcApplication.Model { public class Employee { public int EmployeeId { get; set; } [Required] [StringLength(30)] public string Name { get; set; }
  • 3. [Required] public string AboutMe { get; set; } [Display(Name = "Employee Salary")] [Required] [RegularExpression(@"^$?d+(.(d{2}))?$",ErrorMessage="Employee Salary must be a decimal value")] public decimal Salary { get; set; } } } # List 1: The Employee class deals with coding guides, user about how to use additional attribute: the Display attribute. The Display attributes allows you to modify the property name at the time property is displayed as an error message. Employee class in Listing 1 with Create () controller action feature in Listing 2 can easily be used together. This controller action will again display the Create view property at the time when a model state will contain errors. using System.Web.Mvc; using MvcApplication.Models; namespace MvcApplication.Controllers { public class EmployeeController : Controller { // // GET: /Employee/Create public ActionResult Create() { return View(); } // // POST: /Employee/Create [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create([Bind(Exclude = "EmployeeId")]Employee employeModel) { if (!ModelState.IsValid) return View(); // TODO: Add insert logic here return RedirectToAction("Index"); }
  • 4. } } # List 2: ControllersEmployeeController.cs Create the view feature in Listing 3 by simply right-clicking on Create() action and then select the menu option known as Add View. Create a view with the Employee class as a model class. Again select Create option from the view content dropdown list. @model MvcApplication.Models.Employee @{ ViewBag.Title = "Create"; Layout = "~/Views/Shared/_Layout.cshtml"; } <h2>Create</h2> @using (Html.BeginForm()) { @Html.AntiForgeryToken() <div class="form-horizontal"> <h4>Employee</h4> <hr />
  • 5. @Html.ValidationSummary(true) <div class="form-group"> @Html.LabelFor(model => model.Name, new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.Name) @Html.ValidationMessageFor(model => model.Name) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.AboutMe, new { @class = "control- label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.AboutMe) @Html.ValidationMessageFor(model => model.AboutMe) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.Salary, new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.Salary) @Html.ValidationMessageFor(model => model.Salary) </div> </div> <div class="form-group"> <div class="col-md-offset-2 col-md-10"> <input type="submit" value="Create" class="btn btn-default" /> </div> </div> </div> } <div> @Html.ActionLink("Back to List", "Index") </div> @section Scripts { @Scripts.Render("~/bundles/jqueryval") }
  • 6. # List 3: ViewsEmployeeCreate.cshtml At the time of submitting a form to create any Employee, if you do not enter the specific values for all the required fields, then the validation error messages in Figure 3 will be displayed. If you enter an invalid value in Salary, then the error message in Figure 4 is displayed.
  • 7. # Steps To Work With Data Annotation Validators with the Entity Framework If you are working with the Microsoft Entity Framework to validate a data model class, then it's not possible to apply validator attributes directly to classes. The reason behind this: Entity Framework Designer generates various model classes, and any modifications that are made to the model class will be overwritten next time if you come across with any changes in the Designer. To use validators with classes that are generated by the Entity Framework with ASP.NET MVC, then it's necessary to create metadata classes first. Apply validates to your metadata class. # Figure 5: State class generated by Entity Framework
  • 8. using System.ComponentModel.DataAnnotations; namespace MvcApplication.Model { [MetadataType(typeof(StateMetaData))] public partial class State { } public class StateMetaData { [Required] [Display(Name="State Name")] public object StateName { get; set; } } } # Listing 4: ModelsState.cs The file in Listing 4 comprises of two classes that are known as State class and StateMetaData class. Here State class is a partial class that easily corresponds to the partial class at the time time it is generated by Entity Framework, contained in the DataModel.Designer.vb file. Note: But currently .NET framework does not support partial properties. Here State partial class is developed with MetadataType attribute that signifies the StateMetaData class. StateMetaData class comes with proxy setting properties for State class property. The page in Figure 6 illustrates the error messages returned when you enter invalid values for the State properties.
  • 9. # Figure 6: Using validators with the Entity Framework To work with ASP.NET MVC Data Annotations, it is necessary to hire a highly experienced Asp .NET Developer who possesses high.NET coding skills. # Qualities of a good .NET Developers :-  Experienced and qualified professionals  Strong technical knowledge  Proven methodologies  Effective communication  Thorough technical expertise  Fast turnaround time  Committed to deliver ASP.NET development services to match client's expectaions  Analytical Approach towards programming