- [HttpGet]
- public ActionResult MyMethod()
- {
- return MyMethodHandler();
- }
- [HttpPost]
- [ActionName("MyMethod")]
- public ActionResult MyMethodPost()
- {
- return MyMethodHandler();
- }
- private ActionResult MyMethodHandler()
- {
- // handle the get or post request
- return View("MyMethod");
- }
复制代码
View:
查询调用Get
<%Html.BeginForm("ActionName", "ControllerName", FormMethod.Get);%>
<% Html.Submit("BtnSearchText","btnSearch"); %>
<%Html.EndForm();%>
保存使用Post
<%Html.BeginForm("ActionName", "ControllerName", FormMethod.Post);%>
<% Html.Submit("BtnSaveText","btnSave"); %>
<%Html.EndForm();%>
|