我有一個簡單的形式,看起來像這樣:Html.BeginForm不攜帶其當前PARAMS
@using (Html.BeginForm("search", "home", new { param1 = "value1" }, FormMethod.Get))
{
@Html.TextBox("Search", ViewBag.Search as string)
<button type="submit">Search </button>
}
HTML輸出如下:
<form action="/home/search?param1=value1" method="get">
<input id="Search" name="Search" type="text" value="">
<button type="submit">Search </button>
</form>
和我的控制器看起來是這樣的:
public ActionResult Search(string param1, string search)
{
// param1 returns as "null"
// search contains the value that was inside the textbox
}
有人知道我做錯了什麼?
您可以爲'param1'創建'hidden-field' –
難題... t hanks! –