I using Ajax begin form and when I click submit button, post method doesn’t call, here is code:
@using (Ajax.BeginForm(new AjaxOptions { UpdateTargetId = "personListDivforReturnPerson"}))
{
<div class="ReturnPersonGeneralPageBody">
<div class="returnPersonHeader">
საზღვრის კვეთისას დაფიქსირებული მონაცემები
</div>
<div class="fieldNameForMIA">
<span>@Html.LabelFor(model => model.LastName, "გვარი")
<br />
@Html.EditorFor(model => model.LastName)
</span>
<div class="fieldNameInnerForMIA">
<span>@Html.LabelFor(model => model.FirstName, "სახელი")
<br />
@Html.EditorFor(model => model.FirstName)
</span>
</div>
</div>
<div class="fieldNameForMIA">
<span>@Html.LabelFor(model => model.PersonalNo, "პირადი ნომერი")
<br />
@Html.EditorFor(model => model.PersonalNo)
</span>
<div class="fieldNameInnerForMIA">
<span>@Html.LabelFor(model => model.DateOfBirth, "დაბადების თარიღი")
<br />
@Html.EditorFor(model => model.DateOfBirth)
</span>
</div>
</div>
<div class="fieldNameForReturnCheckBox">
@Html.LabelFor(model => model.IsIdentified, "სხვა სახელით დაბრუნდა")
@Html.CheckBoxFor(model => model.IsIdentified)
</div>
<div class="saveReturnPerson">
<input type="image" name="submit" id="submit" src="/Content/Resources/SaveGeo.gif" />
</div>
</div>
}
and here is post method which is never called:
[HttpPost]
public ActionResult EditReturnPerson(int id, FormCollection collection)
{ ....
but this method is called when first is loaded:
public ActionResult EditReturnPerson(long parentObjectId, int parentObjectTypeId, bool readOnly = false)
{
....
I found my problem, the problem was
[HttpPost] public ActionResult EditReturnPerson(int id, FormCollection collection) { ....in this part, id was int and my id in DB was bigint, so I changed int to long in controller and everything worked, thanks for advice.