开发者

ASP.NET MVC 2 - how to get Ajax.BeginForm work properly inside partial view

I have a View with url like

开发者_StackOverflow中文版/Home/SetResults?patientId=[somePatientId]

, part of it gets conditionaly ajax-updated with some partialview

Inside of that partialView I have this code

<% using (Ajax.BeginForm("Action", "Home", new AjaxOptions { UpdateTargetId = "placeholder", InsertionMode = InsertionMode.Replace,HttpMethod = "Post"})) 
{%>
<div id="placeholder">
....

Whenever I press submit button I get to my simple controller action-method

[HttpPost]
public ActionResult Action(MyModel model)
{
 return PartialView();
}

Everything works fine except the ajax itself - instead of gettin my placeholder updated with the result of controller action I'm always getting redirect to a view with the url of

/Home/Action

So, is it possible to partially update partial view? If yes what I'm doin wrong?


One thing to check would be that you are including the ajax script:

<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>

I've noticed if this isn't included, submitting the Ajax form behaves like a regular submit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜