Ajax.BeginForm没有更新目标div [英] Ajax.BeginForm not updating target div

查看:69
本文介绍了Ajax.BeginForm没有更新目标div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看:



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

{}





型号:





View:

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


Model:


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:

@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.
}

推荐答案

('#myModal1')。modal('hide');}))

{}





型号:





('#myModal1').modal('hide');" }))
{}


Model:


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:

@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.
}


在我看来,你正试图混合Ajax.BeginForm和Html.BeginForm。 Yout代码应该没有@ Html.Beginform块。尝试使用此代码而不使用此块。
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.


这篇关于Ajax.BeginForm没有更新目标div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆