Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
View:

@using (Ajax.BeginForm("AddBranchContact", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "section3", OnSuccess = "$('#myModal1').modal('hide');" }))
{}


Model:


C#
public JsonResult AddBranchContact(BranchViewModel objBranchContact)
     {
      List<BranchContact> BranchContactList = new List<BranchContact>();
         if (Session["BranchContactList"] == null)
         {
             BranchContactList.Add(objBranchContact.BranchContactDetails);
             Session["BranchContactList"] = BranchContactList;
         }
         else
         {
         } 
         return Json(BranchContactList, JsonRequestBehavior.AllowGet);
     }


View:

HTML
@using (Html.BeginForm())
{

<div id="section3"><table>


</table></div>

The results returned from the action below are displayed in tr tds of this table. But when the action method below is called it gets the data but doesnt come back to this part : @using(Html.BeginFOrm()) even though i have given the UpdateTargetID as above.
}
Posted
Updated 6-Apr-19 4:49am

1 solution

It seems to me, You are trying to mix Ajax.BeginForm and Html.BeginForm. Yout code should work without @Html.Beginform block. Try to use this code without this block.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900