如何在单个Razor视图中使用2个表单在mvc4中编写控制器

时间:2013-08-17 11:03:57

标签: asp.net-mvc-4

我在Login register.html页面中有两个表单,如下所示:

@using (Html.BeginForm("Tests1", "Test", FormMethod.Post, 
                       new { id = "FormSearch1" }))
{ 
    <input type ="submit"  value="Filter1 " id="submit" />
}

和另一种形式如下:

@using (Html.BeginForm("Tests2", "Test", FormMethod.Post, 
                       new { id = "FormSearch2" }))
{ 
    <input type ="submit"  value="Filter2 " id="save" />
}

所以这次如何在控制器中写入动作结果?

1 个答案:

答案 0 :(得分:0)

[HttpPost]    
public ActionResult Test1()
{
    ViewBag.Message = "Your app description page.";
    return View("sameViewForBoth");
}

[HttpPost]    
public ActionResult Test2()
{
    ViewBag.Message = "Your app description page.";
    return View("sameViewForBoth");
}