In the View Add Hidden field
@Html.Hidden(initialProductCode, Model.ProductCode)
In the Remote attribute Add AdditionalFields
[Remote("ValidateProductcode", "Controller", ErrorMessage = "Product Code already exists.", AdditionalFields = "initialProductcode")]
and the Controller action function
public JsonResult ValidateProductcode(string Productcode, string initialProductcode)
{
try
{
if (Productcode == initialProductcode)
{
return Json(true, JsonRequestBehavior.AllowGet);
}
var Productcode = datacontext.tablename.Single(m => m.ProductCode == Productcode);
return Json(false, JsonRequestBehavior.AllowGet);
}
catch (Exception)
{
return Json(true, JsonRequestBehavior.AllowGet);
}
}