difference between Html.BeginForm() and ajax.beginform()

前端 未结 3 630
长发绾君心
长发绾君心 2021-01-04 01:12

what is the difference between Html.BeginForm() and Ajax.Beginform() in MVC3. I just want to know the scenarios where I can use Html.BeginFor

相关标签:
3条回答
  • 2021-01-04 01:49

    Html.BeginForm() will create a form on the page that submits its values to the server as a synchronous HTTP request, refreshing the entire page in the process.

    Ajax.BeginForm() creates a form that submits its values using an asynchronous ajax request. This allows a portion of the page to be update without requiring that the entire page be refreshed.

    0 讨论(0)
  • 2021-01-04 01:51

    Html.BeginForm() will use simple posting on page, it means your page will be refreshed when you post your form. when Ajax.BeginForm() will use ajax posting on page, it means your page will not be refreshed when you post your form.

    0 讨论(0)
  • 2021-01-04 01:57

    Ajax

    1. Won't redirect the form even you do a RedirectAction().
    2. Will perform save , update and any modification operations asynchronously.
    3. Validate the Form using FormMethods - OnSubmit. So you are abort the Post
    4. This creates a form that submits its values using an asynchronous ajax request. This allows a portion of the page to be update without requiring that the entire page be refreshed.

    Html

    1. Will redirect the form.
    2. Will perform operations both Synchronously and Asynchronously (With some extra code and care).
    3. Html.BeginForm will always use RouteTable to detrmine the action attribute value.
    4. This will create a form on the page that submits its values to the server as a synchronous HTTP request, refreshing the entire page in the process.
    0 讨论(0)
提交回复
热议问题