May 11, 2018, 1:50 AM
How to use RemoteAttribute of mode in Ext.net
I use RemoteAttribute of mode but it doesn't work with Ext.net. It alway show "UOM code already exists. Please specify another one."
public class UOMEditViewModel
{
public Int64 Id { get; set; }
[Required]
[Display(Name = "Code")]
[Remote("CheckDuplicateUom", "Validation", AreaReference.UseRoot, AdditionalFields = "Id", ErrorMessage = "UOM code already exists. Please specify another one.")]
[RegularExpression(@"^[A-Za-z0-9]*$", ErrorMessage = "Invalid Code - only allow a-z A-Z 0-9 character")]
public String Code { get; set; }
[Required]
[Display(Name = "Description")]
public String Description { get; set; }
[Required]
[Display(Name = "Status")]
public DefaultStatusType Status { get; set; }
public Int64 Version { get; set; }
}
Here is my controller [OutputCache(Location = OutputCacheLocation.None, NoStore = true)]
public class ValidationController : BaseController
{
public JsonResult CheckDuplicateUom(UOMEditViewModel uom)
{
var repository = new UomRepository();
Uom exists;
if (uom.Id != null && uom.Id != 0)
exists = repository.GetBy(c => c.Code.Equals(uom.Code, StringComparison.InvariantCultureIgnoreCase) && c.Id != uom.Id);
else
exists = repository.GetBy(c => c.Code.Equals(uom.Code, StringComparison.InvariantCultureIgnoreCase));
return Json(exists != null, JsonRequestBehavior.AllowGet);
}
}
}
Last edited by hat04; May 11, 2018 at 2:15 AM.
Reason: Add detail error