且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从点击一个按钮,在ASP.NET MVC调用操作方法

更新时间:2023-01-07 08:27:34

通过按钮,它涉及JQuery的或JavaScript打电话到从服务器获取数据,如果你想这样做的AJAX形式。但是,在最简单的形式,这样做的:

With buttons, it has to involve JQuery or JavaScript to make a call to get the data from the server, if you want to do it in AJAX form. But in its simplest form, doing:

<% Html.BeginForm("Action", "Controller"); %>

 <!--Form values in here-->

 <input type="submit" />

<% Html.EndForm(); %>

将调用您的操作方法,并调用回发。有一个在System.Web.Mvc.Ajax一个AJAX选择使用与AJAX选项的当作ajaxForm做回发异步,而且很容易安装。我倾向于使用jQuery,而不是个人。

Will invoke your action method and invoke a postback. There is an AJAX option in the System.Web.Mvc.Ajax to use an AjaxForm with AJAX options for doing the postback async, and it's easy to setup. I tend to use JQuery instead personally.

HTH。