Y G

Y G

  • NA
  • 236
  • 30.5k

ASP.NET MVC USING JQUER AJAX

Oct 14 2016 2:16 AM
Can anyone please tell me how to post these values from view to controller and there by from controller to database by creating objects:
 
 
 
@model task.tabPerson1
@{
ViewBag.Title = "Edit";
}
<h2>Edit</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>tabPerson1</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.personId)
<div class="form-group">
@Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DisplayFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.mobileNo, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.mobileNo, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.mobileNo, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.HowManyAddress, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.HowManyAddress, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.HowManyAddress, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.sequenceNo, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.sequenceNo, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.sequenceNo, "", new { @class = "text-danger" })
</div>
</div>
</div>
}
@foreach (var item in Model.tabAddress1)
{
<table>
<tr>
<tr><td>Person Id</td><td>:</td><td> <input type="text" value="@Html.DisplayFor(modelItem => item.personId)" /></td></tr>
<tr><td>address Id</td><td>:</td><td><input type="text" value="@Html.DisplayFor(modelItem => item.addId)" /></td></tr>
<tr><td> country</td><td>:</td><td><input type="text" value="@Html.DisplayFor(modelItem => item.country)" /></td></tr>
<tr><td>city</td><td>:</td><td><input type="text" value="@Html.DisplayFor(modelItem => item.city)" /></td></tr>
<tr><td>Addresses</td><td>:</td><td><input type="text" value="@Html.DisplayFor(modelItem => item.Addresses)" /></td></tr>
</table>
}
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
<div>
@Html.ActionLink("Back to List", "getPersonDetails")
</div>

Attachment: PostEdit.zip

Answers (1)