or
public class Client{ [ScaffoldColumn(false)] public int Id { get; set; } [DisplayName("Name")] [Required] [StringLength(120)] public string Name { get; set; }
​ // etc...
public virtual Address Address { get; set; }
}
public class Address{ [ScaffoldColumn(false)] public int AddressId { get; set; } [DisplayName("Address")] [Required] [StringLength(200)] public string Street { get; set; } // etc... [ForeignKey("Client")] public int? Id { get; set; } public virtual Client Client { get; set; }}@using (Html.BeginForm("Create", "Client", FormMethod.Post, new Dictionary<string, object> { { "data-htci-target", "addressData" } })){ @Html.AntiForgeryToken() <div class="row"> @Html.LabelFor(model => model.Name, new { @class = "control-label col-md-2" }) <div class="col-sm-4 col-md-4 col-lg-4"> @Html.Kendo().AutoCompleteFor(model => model.Name).HtmlAttributes(new { style = "width:100%" }) @Html.ValidationMessageFor(model => model.Name) </div> </div> @{ var vdd = new ViewDataDictionary(ViewData) { TemplateInfo = new TemplateInfo() { HtmlFieldPrefix = "Address" } };} @Html.Partial("_AddressPartial", Model.Address, @vdd) // yada yada...you can imagine the rest of the very standard view$(function() { var urlGeoIeoip = "http://ip-api.com/json/?callback=?"; $.ajax({ url: urlGeoIeoip, type: "GET", dataType: "json", timeout: 5000, success: function (geoipdata) { $.ajax({ url: "/getlocationdata/" + geoipdata.country + "/" + geoipdata.regionName + "/" + geoipdata.city, type: "GET", timeout: 5000, success: function (data) { //alert(data); //var $form = $(this); // var $target = $($form.attr("data-htci-target")); var $newHtml = $(data); //alert($target); $("#addressData").replaceWith($newHtml); $("#City").data("kendoComboBox").value(geoipdata.city); $("#State").data("kendoComboBox").value(geoipdata.regionName); $("#Country").data("kendoComboBox").value(geoipdata.country); } });}}).fail(function(xhr, status) { if (status === "timeout") { // log timeout here } });});