【问题标题】:How to get hit to httpPost action on clicking on sorting and paging in a webgrid MVC3?如何在 webgrid MVC3 中单击排序和分页时点击 httpPost 操作?
【发布时间】:2013-01-16 09:42:47
【问题描述】:

我是 MVC3 的新手

我有一个带有 webgrid 的页面和 httpget 上的一些搜索选项我的 webgrid 是空白的,因为我的功能就像 webgrid 在我的搜索后会有一些数据(意味着在页面发布之后并且它工作正常)。 现在, 我正在使用带有一些自定义搜索过滤器的 webgrid。当我在 GRID 中单击、分页或排序时,它会转到 HttpGet 而不是 HttpPost,并且从 HttpGet 返回 null 值并且网格会消失。

希望我没有让大家感到困惑。

谢谢..

【问题讨论】:

  • 您需要提供一些代码供我们查看。
  • 你有什么尝试,请给我们一些代码。也供您参考check this

标签: c# asp.net-mvc-3 webgrid


【解决方案1】:

将控制器操作标记为[HttpPost],并确保您通过提交表单来发布数据。

[HttpGet]
public ActionResult Search()
{

}

[HttpPost]
[ActionName("Search")]
public ActionResult SearchPost(/* search params*/)         //this method should get called
{
 /*your code*/`enter code here`
}

【讨论】:

    猜你喜欢
    • 2013-04-21
    • 1970-01-01
    • 2011-11-24
    • 1970-01-01
    • 2012-03-03
    • 2011-09-14
    • 2012-07-28
    • 2012-01-16
    • 1970-01-01
    相关资源
    最近更新 更多