Dear ...
I have don't call particular validation in my web Page.
My class file.
public partial class AssessmentReporttext
{
public int ID { get; set; }
[Required(ErrorMessage = "Assessment is required")]
public string Assessment { get; set; }
[Required(ErrorMessage = "Codetype is required")]
public string CodeType { get; set; }
[Required(ErrorMessage = "Description is required")]
public string Description { get; set; }
[Required(ErrorMessage = "Score is required")]
public string Score { get; set; }
public Nullable<System.DateTime> CreateDate { get; set; }
public Nullable<System.DateTime> ModifiedDate { get; set; }
}
And From Code..
@using (Html.BeginForm())
{
@Html.LabelFor(model => model.Assessment)
@*@Html.EditorFor(model => model.Assessment)*@
@Html.DropDownList("Assessment", new SelectList(Enum.GetValues(typeof(MovingCorrectly.Common.CommonEnums.ReportAssessmentType))), "Select")
@Html.ValidationMessageFor(model => model.Assessment, null, new { @class = "redtext" })
@Html.LabelFor(model => model.CodeType)
@*@Html.TextAreaFor(model => model.CodeType, new { cols = "50" })*@
@Html.DropDownList("CodeType", new SelectList(Enum.GetValues(typeof(MovingCorrectly.Common.CommonEnums.Codetype))), "Select")
@Html.ValidationMessageFor(model => model.CodeType, null, new { @class = "redtext" })
@Html.LabelFor(model => model.Score)
@Html.DropDownList("Score", new SelectList(Enum.GetValues(typeof(MovingCorrectly.Common.CommonEnums.ReportScore))), "Select")
@Html.ValidationMessageFor(model => model.Score, null, new { @class = "redtext" })
@Html.LabelFor(model => model.Description)
@Html.TextAreaFor(model => model.Description, new { cols = "50", @maxlength = "1000" })
@Html.ValidationMessageFor(model => model.Description, null, new { @class = "redtext" })
}
========
If i am change some value select then fair validation otherwise not fair in validation.