Validating data in asp
Validating data in asp - pearls before swine christian dating rules
NET Entity Data Model to the project so that you get the User Profile entity class as shown above.
If an error message is not specified, a default error message is displayed.The recommended approach is to create a metadata class and decorate its properties with data annotation attributes. Add a new class in the Models folder and name it User Profile Metadata.Write the following code in the User Profile Metadata class.The User Profile Metadata class contains property definitions for First Name, Last Name, Email, Bio, Age, Blog Url and Phone.Notice the attributes that are used to decorate these properties.The [Metadata Type] attribute accepts the type of the class that is supplying metadata information to the User Profile class (User Profile Metadata in this case).
Now, add a new controller in the Controllers folder and name it Home Controller.
In this example you validate the Phone property with a regular expression for US phone numbers.
At this stage, the User Profile Metadata class is just an independent class in your project.
Add the following code to the Home Controller class.
The Home Controller class contains two versions of the Index() action method.
The [Required] attribute indicates that a property value must be provided.