qua*_*els 2 forms asp.net-mvc post get asp.net-mvc-2
我的代码很简单:
<% using(Html.BeginForm(FormMethod.Get)) %>
<% { %>
Search for in Screen Name and Email: <%: Html.TextBox("keyword", Request.QueryString["keyword"]) %>
<button type=submit>Search</button>
<% } %>
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,当我提交此表单时,值不会添加到查询字符串中.相反,似乎表单是通过发布请求提交的.当我查看生成的HTML时,我有:
<form action="/find/AdminMember/MemberList" method="post">
Search for in Screen Name and Email: <input id="keyword" name="keyword" type="text" value="" />
<button type=submit>Search</button>
</form>
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么?对我来说这看起来非常简单和直截了当.
BeginForm帮助器的正确签名是这样的:
<% using(Html.BeginForm("SomeAction", "SomeController", FormMethod.Get)) %>
<% { %>
Search for in Screen Name and Email:
<%: Html.TextBox("keyword", Request.QueryString["keyword"]) %>
<button type="submit">Search</button>
<% } %>
Run Code Online (Sandbox Code Playgroud)
在编写时,BeginForm(FormMethod.Get)您基本上调用此签名,其中routeValues参数与之无关,FormMethod.Get并且使用POST作为默认动词.
| 归档时间: |
|
| 查看次数: |
1435 次 |
| 最近记录: |