I have an MVC grid which calls an external FormLayout
I have some Annotations on the Model with the Required Tag
These are showing fine on the Form with a marker beside the field (i,e. they show a --> *)
Also, I am not allowed Save unless these are filled in
However, whats not happening is the the Error Message is not being displayed when I try to Save
How do I get the ErrorMessage to show to the Right of the field (In red) if there is an error on the field
C#namespace Club.Models
{
[MetadataType(typeof(MemberMD))]
public partial class Member
{
}
public class MemberMD
{
[Required(ErrorMessage= "First Name is required")]
[Display(Name = "First Name")]
public string FirstName { get; set; }
[Required(ErrorMessage= "Surname is required")]
[Display(Name = "Sur Name")]
public string SurName { get; set; }
[Display(Name = "Mobile")]
public string TelMobile { get; set; }
[Display(Name = "Home Tel")]
public string TelHome { get; set; }
}
}
HTML@model Club.Models.Member @{ Html.EnableClientValidation(); Html.EnableUnobtrusiveJavaScript(); } @using(Html.BeginForm("ExternalEditFormEdit","Member",FormMethod.Post, new { @class = "edit_form"})) { @Html.DevExpress().FormLayout(settings => { settings.Name = "Member Details"; var mainDetails = settings.Items.AddGroupItem("Main Details"); mainDetails.Items.Add(i => i.MemberId); mainDetails.Items.Add(i => i.Salutation); mainDetails.Items.Add(i => i.FirstName); mainDetails.Items.Add(i => i.SurName); mainDetails.Items.Add(i => i.Gender); mainDetails.Items.Add(i => i.TelMobile); mainDetails.Items.Add(i => i.TelHome); mainDetails.Items.Add(i => i.Email); mainDetails.Items.Add(i => i.DateOfBirth); var memberDetails = settings.Items.AddGroupItem("Membership Details"); memberDetails.Items.Add(i => i.DateJoined); memberDetails.Items.Add(i => i.CurrentSubType); memberDetails.Items.Add(i => i.RenewalDate); var adrDetails = settings.Items.AddGroupItem("Address Details"); adrDetails.Items.Add(i => i.Ad1); adrDetails.Items.Add(i => i.Ad2); adrDetails.Items.Add(i => i.Ad3); adrDetails.Items.Add(i => i.Town); adrDetails.Items.Add(i => i.County); adrDetails.Items.Add(i => i.Country); }).GetHtml() @Html.DevExpress().Button( settings => { settings.Name = "btnUpdate"; settings.ControlStyle.CssClass = "button"; settings.Text = "Update"; settings.UseSubmitBehavior = true; }).GetHtml() @Html.DevExpress().Button( settings => { settings.Name = "btnCancel"; settings.ControlStyle.CssClass = "button"; settings.Text = "Cancel"; settings.ClientSideEvents.Click = "function(s, e){ document.location='" + DevExpressHelper.GetUrl(new { Controller = "Member", Action = "MembersMaintain" }) + "'; }"; }).GetHtml() }