如何将这一行 HTML 变成 HTML 助手?

How can I turn this line of HTML into an HTML helper?

 <input type="text" name="search" id="search" style="border-style:ridge;" />

那是 Html 的那一行我想把它作为 html 的助手。我试过了:

@Html.TextBox(" ", "",new { id="search", name="search", style="border-style:ridge;"})

但是当我按 enter 时它不会 post 返回那个文本框。它适用于输入标签。

那只是一个普通的盒子:

@Html.TextBox("search", null, new { style = "border-style: ridge;" })

或者假设您的模型有 search 属性,它将是:

@Html.TextBoxFor(x => x.search, new { style = "border-style: ridge;" })

这两个产生相同的 HTML。除非发生任何有趣的事情,否则文本框的 ID 和名称都将是 search.