- Information
- AI Chat
Was this document helpful?
CS 3203 Software Engineering Lab 8
Course: Software Engineering (CS391)
174 Documents
Students shared 174 documents in this course
University: Fayoum University
Was this document helpful?
Eng. Yossr - Eng. Esraa
1
Data Annotation Attributes in ASP.NET MVC
The System.ComponentModel.DataAnnotations assembly has many built-in validation
attributes, for example:
1. Required
2. Range
3. RegularExpression,
4. Compare
5. StringLength
6. Data type
7. Password
8. Phone number
Account.cs file to the Mode
namespace WebApplicationAccountSec.Models
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
public partial class NewUser
{
public int Id { get; set; }
//Data validation
[Required(ErrorMessage ="enter your name")]
public string Name { get; set; }
[Required(ErrorMessage = "enter your email")]
[DataType(DataType.EmailAddress)]
public string email { get; set; }
[Required(ErrorMessage = "enter your city")]
public string City { get; set; }
[Required(ErrorMessage = "enter your password")]
[DataType(DataType.Password)]
public string password { get; set; }
[Required(ErrorMessage = "enter your confirm")]
[DataType(DataType.Password)]
[Compare("password",ErrorMessage ="not match")]
public string confirmpass { get; set; }
}
}
CS 3203 Software Engineering (1) – 2020/2021
Lab (8)