How to use RemoteAttribute of mode in Ext.net

  1. #1

    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
  2. #2

    I have found solution. Please check

      public JsonResult ExtCheckDuplicateUom(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 new JsonResult
                {
                    Data = new
                    {
                        serviceResponse = new
                        {
                            valid = exists == null
                        }
                    }
                };
            }

Similar Threads

  1. [CLOSED] Compatibility Mode in IE 9
    By aisi_it_admin in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: Aug 27, 2012, 10:38 AM
  2. I am not able to view in Designer mode plz help
    By rizwanitarsi in forum 1.x Help
    Replies: 3
    Last Post: Jul 20, 2011, 10:12 PM
  3. Calendar in readonly mode
    By reiben in forum 1.x Help
    Replies: 9
    Last Post: Dec 02, 2010, 6:55 AM
  4. [CLOSED] Ext.Net 1.0 using II 7.0 Integrated Mode.
    By Zarzand in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 25, 2010, 6:55 PM

Posting Permissions