Hi
@model MyApplication.Models.Location
@using (Html.BeginForm("CreateEdit", "Location", FormMethod.Post)) { @Html.AntiForgeryToken() @Html.ValidationSummary(true, "", new { @class = "text-danger" }) <input type="hidden" name="hfId" id="hfId" value="" /> <div class="modal" tabindex="-1" role="dialog" id="UpSertModal"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title"></h4> </div> <div class="modal-body"> <div class="form-horizontal"> <div class="form-group"> @Html.LabelFor(model => model.Id, htmlAttributes: new { @class = "control-label col-md-3" }) <div class="col-md-3"> @Html.EditorFor(model => model.Id, new { htmlAttributes = new { @class = "form-control", @Value = Model.Id } }) @Html.ValidationMessageFor(model => model.Id, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.Description, htmlAttributes: new { @class = "control-label col-md-3" }) <div class="col-md-9"> @Html.EditorFor(model => model.Description, new { htmlAttributes = new { @class = "form-control", @Value = Model.Description } })
@Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" }) </div> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> <button type="submit" class="btn btn-primary">Save Changes</button> </div> </div> </div> </div> }
*******************Controller
[HttpGet] public ActionResult CreateEdit(string Id) { Id = Id.Trim(); ////try ////{ if (String.IsNullOrEmpty(Id)) { return PartialView("_CreateEdit", new Location()); }
else { return PartialView("_CreateEdit", dbLocation.GetById(Id)); } //} //catch (Exception ex) //{ // ExceptionLogging.SendExcepToDB(ex); // TempData["Message"] = "Error Encountered."; //} }
Thanks