The text of this article is not in this database — only its details are. Read it on the old site: Validation Using Data Annotations In ASP.NET MVC 5
9 Comments
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
The text of this article is not in this database — only its details are. Read it on the old site: Validation Using Data Annotations In ASP.NET MVC 5
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
Shabbir HusainPosted Feb 2, 2018, 4:41 AM
Can u please upload the source code as well for ua every article in .rar or zip??
Anil kumarPosted Oct 9, 2017, 6:47 AM
Hi Rupesh Kahane , I'm trying to do validation using DataAnnotations almost done but validation messages not displaying can you please help. @using (Html.BeginForm("Index", "Home", FormMethod.Post, new { @class = "form-horizontal", role = "form" })){@*@Html.AntiForgeryToken()*@@Html.ValidationSummary(false) <div class="form-group"> @Html.Label("Employee Name", new { @class = "col-md-2 control-label" }) <div class="col-md-10"> @Html.TextBoxFor(m => m.objemployeeinfo.EmployeeName, new { @class = "form-control", Name = "EmployeeName" }) @Html.ValidationMessageFor(m => m.objemployeeinfo.EmployeeName) </div> </div> <div class="form-group"> @Html.Label("Email ID", new { @class = "col-md-2 control-label" }) <div class="col-md-10"> @Html.TextBoxFor(m => m.objemployeeinfo.EmailID, new { @class = "form-control",Name= "EmailID" }) @Html.ValidationMessageFor(m => m.objemployeeinfo.EmailID) </div> </div> <div class="form-group"> @Html.Label("Contact Number", new { @class = "col-md-2 control-label" }) <div class="col-md-10"> @Html.TextBoxFor(m => m.objemployeeinfo.ContactNumber, new { @class = "form-control", Name = "ContactNumber" }) @Html.ValidationMessageFor(m => m.objemployeeinfo.ContactNumber) </div> </div> <div class="form-group"> <div class="col-md-offset-2 col-md-10"> <input type="submit" class="btn btn-default" value="Save" /> </div> </div> } ===============Model Class========================= public class EmployeeInfo { public int EmployeeID { get; set; } [Display(Name = "Employee name")] [Required (ErrorMessage ="Employee name required.")] public string EmployeeName { get; set; } [Required(ErrorMessage = "Email id required.")] public string EmailID { get; set; } [Required(ErrorMessage = "Contact Number required.")] public string ContactNumber { get; set; } public string Department { get; set; } public string EmployeeType { get; set; } public string Roles { get; set; } } .
Rupesh KahanePosted Dec 30, 2015, 10:06 PM
thanks to Ankur Mistry, sreenivasa k & Raja T sir also
Raja TPosted Dec 30, 2015, 9:58 PM
Nice, thanks for sharing
sreenivasa kPosted Dec 30, 2015, 4:13 PM
good article
Ankur MistryPosted Dec 30, 2015, 1:07 PM
Helpful article Rupesh Kahane
Rupesh KahanePosted Dec 30, 2015, 9:13 AM
Thanks to Humayun Kabir Mamun and @Santhakumar also
Humayun Kabir MamunPosted Dec 30, 2015, 7:13 AM
Nice...
Santhakumar MunuswamyPosted Dec 30, 2015, 6:17 AM
Thanks for nice share