我正在asp.net mvc的网站上工作。我必须展示一个视图,用户在其中放置一些搜索值,例如标签和标题以进行搜索。我想为此使用相同的Index方法。我有 使我的表单使用formMethod.Get发送参数作为查询字符串。FormMethod.Get和查询字符串参数
所以这里是方法
[HttpGet]
public ActionResult Index(string title, string tags, int? page)
{
if (string.IsNullOrEmpty(title)
return View(null);
var list = GetSomeData();
return View(list);
}
这里是我的看法
<div id="searchBox">
<% using (Html.BeginForm(null, null, FormMethod.Get))
{ %>
<table>
<tr>
<td>
<input type="hidden" id="isPosted" name="isPosted" value="1" />
I am looking for
<%=Html.TextBox("Title")%>
Tags:
<%=Html.TextBox("Tags")%>
<input id="search" type="submit" value="Search" />
</td>
</tr>
</table>
<% } %>
因此,当用户第一次访问该页面时,他只能看到两个文本boxs和一个按钮。但是当他在标题和标签中键入内容并单击搜索按钮时,我将用一些数据加载视图。
现在的问题是,当我在标题和标签框中键入内容并单击搜索时,它们在方法中收到,但在url中不可见。有什么我做错了。
帮助将不胜感激。
问候
成员Parminder
他可能令人困惑的mvc与webforms是我认为它可能是 – griegs 2010-05-28 04:14:50
也许他意味着ist不是可见的URL的路由部分,但只在查询字符串。 – 2010-05-28 09:58:49
它的mvc,但当我张贴表格。这些参数不是url字符串的一部分。我所做的是手动添加使用JavaScript的所有参数,并将location.href设置为相同的方法。 – Parminder 2010-05-29 03:42:23