I have a database which contains city(sehir) and district(il) tables. In my registration form I want to fetch district data depending on city value. And there is a address table which has foreign keys to these tables. There is a column for postal code. First I made it integer value, when I tried it like […]
- Tags 'required' => 'required', "", "CA2214:DoNotCallOverridableMethodsInConstructors")] public tblİlce() { this.tblAdres = new HashSet();, "CA2214:DoNotCallOverridableMethodsInConstructors")] public tblKullanici() { this.tblBagis = new HashSet<tblBagis, "CA2214:DoNotCallOverridableMethodsInConstructors")] public tblSehir() { this.tblAdres = new HashSet();, "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection tblAdres { get; set; } [System.Diagnosti, "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection tblAdres { get; set; } } City(sehir) model:, "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection tblAdres { get; set; } } Thank you all for, "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection tblBagis { get; set; } [System.Diagnosti, "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection tblSiparis { get; set; } } District(ilce), "tip": "ilceGetir" }, { type: 'text', @required = "required" } }) @Html.ValidationMessageFor(model => model.Address.acikAdres, @required = "required" } }) @Html.ValidationMessageFor(model => model.User.firmaAdi, @required = "required" } }) @Html.ValidationMessageFor(model => model.User.kullaniciAdi, @required = "required" } }) @Html.ValidationMessageFor(model => model.User.telefon, @type = "password" } }) @Html.ValidationMessageFor(model => model.User.sifre, @type = "text" } }) @Html.ValidationMessageFor(model => model.Address.postaKodu, @type = "text" } }) @Html.ValidationMessageFor(model => model.User.mail, //controllerımda gidicek olan yerim dataType: "json" }); $.extend({ ilGetir: function () {, ErrorMessage = "Açık adres en az 30 karaktere sahip olmak zorundadır")] public string acikAdres { get; set; } [Required(Erro, ErrorMessage = "E-mail en fazla 70 karaktere sahip olabilir!")] public string mail { get; set; } [Required(ErrorMessage = "T, ErrorMessage = "Firma adınız en fazla 70 karakter olabilir!")] public string firmaAdi { get; set; } [Required(AllowEmptyStri, ErrorMessage = "Kullanıcı adınız 6 ila 30 karakter arasında olmak zorundadır!")] public string kullaniciAdi { get; set; } [R, ErrorMessage = "Posta kodu maksimum 6 haneye sahip olabilir!")] public string postaKodu { get; set; } [Required(ErrorMessage, ErrorMessage = "Şifre girmeniz gerekmektedir!")] [DataType(DataType.Password)] [StringLength(35, ErrorMessage = "Şifreler uyuşmamaktadır!")] public string sifreTekrar { get; set; } [Required(ErrorMessage = "E-mail girmeni, ErrorMessage = "Telefon numaranız en fazla 16 haneli olabilir!")] public string telefon { get; set; } public System.DateTime, ErrorMessage =("Şifreniz 6 ila 35 karakter arasında olmak zorundadır"))] public string sifre { get; set; } [NotMapped], false); $.each(sonuc.text, FormMethod.Post, function () { //seçili olan id alıyoruz var ilID = $(this).val(); //seçili olan idmizi ilceGetir'imze gön, function (index, I have a database which contains city(sehir) and district(il) tables. In my registration form I want to fetch district data depending on city, ilceGetir: function (ilID) { $.ajax({ //ekstra olarak functionumaza gelen ilID mizi gönderiyoruz, it contains jQuery code for ajax @model IWP.Models.RegisterVM @{ ViewBag.Title = "Register"; } Kayıt Formu @if (ViewB, item) { var optionhtml = '' + item.Text + '';, MinimumLength = 6, my ajax call was working properly it was fetching all city and district data dynamically. But when I submitted form i got an error which says, new { @class = "text-danger" }), new { @class = "text-danger" }) Kullanıcı adı<, new { @class = "w-100 d-flex justify-content-center" })) { @Html.AntiForgeryToken() <div class="form-horizontal p-5 m-3 w-50 d-flex f, new { htmlAttributes = new { @class = "form-control", string tip) { db = new DatabaseContext(); List sonuc = new List();, success: function (sonuc) { //bir önceki kayıtları temizliyorum $("#ilce option").remove();, success: function (sonuc) { //gelen sonucumuz kontrol ediyoruz ona göre selectimze append işlemi gerçekleştiyoruz, text = sonuc }); } here is my register view, the thing is that my ajax call has nothing to do with postal code. My Code: Address Class: public int kullaniciID { get; set; } pub, this time my ajax call was not working properly, url: "/User/IlIlce", User>();, Value = "Default" }); } //Oluşturduğum sonucları json olarak geriye gönderiyorum return, Value = ilce.ilceID.ToString() }); } break;, Value = sehir.sehirID.ToString() }); } break;, when I did it this way, when I tried it like this