Using Ajax.BeginForm with ASP.NET MVC 3 Razor

后端 未结 8 1020
面向向阳花
面向向阳花 2020-11-22 01:23

Is there a tutorial or code example of using Ajax.BeginForm within Asp.net MVC 3 where unobtrusive validation and Ajax exist?

This is an elusive topic f

8条回答
  •  时光说笑
    2020-11-22 01:41

    I think that all the answers missed a crucial point:

    If you use the Ajax form so that it needs to update itself (and NOT another div outside of the form) then you need to put the containing div OUTSIDE of the form. For example:

     
    @using (Ajax.BeginForm("MyAction", "MyController", new AjaxOptions { HttpMethod = "POST", InsertionMode = InsertionMode.Replace, UpdateTargetId = "target" })) { }

    Otherwise you will end like @David where the result is displayed in a new page.

提交回复
热议问题