Sunday, 15 June 2014

asp.net mvc - Remote validation not working for MVC -


I have done a remote verification in my project to avoid duplicate entries in DB. My model class is like this

  public class supplier (public IA supplier) {get; Set; } Public String SupplierName {get; Set; } [Required, DisplayName ("Supplier Code")] [Remote ("ViCodeExists", "Supplier", "V Code already exists", Additional files = "SupplierID")] Get Public String Supplier Code; Set; }}  

and my inside the Supplier Controller I have such a function

  public JsonResult ViCodeExists (String Suppliers Code, Int SupplierId = 0) {var user = _db.Suppliers.Where (x => x.SupplierCode == Supplier Code.Rim () & X. SupplierId !: Supplier ID;); Come back! the user. someone ()? Jason (True, Jesenheim Beavier. Approved): Jason (String format ("{0} already exists.", Suppliers Code), Zennewfest Behavior Alowweight); }  

In my create view

  @html Textboxford (model => model. SUPPLRoad) @html. Validation message (Model = & Model; Model Supplier Code)  

Everything looks fine for me, but this verification does not work. I have tried to add breakpoints inside the controller, but it can never be hit. Does anyone here tell me what I am doing wrong here?

Note: I have the same type of validation in some other controllers of the same project and they all work well. The problem is with only one.

You accept RemoteAttribute 3 string parameters where 3 parameters area name (No error message) [Remote ("ViCodeExists" "Supplier", error message = "V code already exists", Additional files = "SupplierID")] Public string Recipient Code {Received; Set; }

Note that overriding an error message in the notification return statement, so that you might leave it and simply

  [Remote ("ViCodeExists" , "Supplier", Additional Files = "Supplier ID")] Public String Supplier Code {Received; Set; }  

No comments:

Post a Comment