Ajax.BeginForm results in redirect to partial view instead of in-place

前端 未结 2 1579
一向
一向 2021-01-22 12:42

My Search.cshtml has a div named \"search-results\" that is to be updated. SearchResults is the action name. I have done this many times on MVC2/VS2008 projects, but this is my

相关标签:
2条回答
  • 2021-01-22 13:13

    Ok, figured out my problem.

    I was calling Ajax.BeginForm with the AjaxOption OnSuccess pointint to a js function that updated my place holder. But this is not needed, with unobtrusive. Once I removed the OnSucces from the Ajax options everything started working.

    ~S

    0 讨论(0)
  • 2021-01-22 13:25

    You forgot to include the jquery.unobtrusive-ajax.js script to your page (adjust the path as necessary):

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

    As far as Microsoft*.js scripts are concerned, they are obsolete in ASP.NET MVC 3 and should no longer be used unless you are porting some legacy application. They have been replaced by jQuery.

    0 讨论(0)
提交回复
热议问题