我的母版页中有一个简单的搜索表单和一个serach控制器和视图.我正在尝试为字符串搜索术语"myterm"(例如)获取以下路由:root/search/myterm
母版页中的表单:
<% using (Html.BeginForm("SearchResults", "Search", FormMethod.Post, new { id = "search_form" }))
{ %>
<input name="searchTerm" type="text" class="textfield" />
<input name="search" type="submit" value="search" class="button" />
<%} %>
Run Code Online (Sandbox Code Playgroud)
控制器行动:
public ActionResult SearchResults(string searchTerm){...}
Run Code Online (Sandbox Code Playgroud)
我正在使用的路线:
routes.MapRoute(
"Search",
"search/{term}",
new { controller = "Search", action = "SearchResults", term = (string)null }
);
routes.MapRoute(
"Default",
"{controller}/{action}",
new { controller = "Home", action = "Index" }
);
Run Code Online (Sandbox Code Playgroud)
无论我输入什么搜索词,我总是在没有搜索词的情况下获取网址"root/search".
谢谢.
我和班级"myanchor"有几个链接.我想为每个链接显示一个div(onmouseover)和hide(onmouseout):
"link1"显示"div1""link2"显示"div2"...
我的代码不起作用:
$(document).ready(function () {
var n = $(".myanchor").length;
var arr = [];
for (var i = 1; i <= n; i++) {
arr[i] = i;
};
jQuery.each(arr, function () {
$("#anchor" + this, "#div" + this).mouseover(function () {
$("#div" + this).show();
}).mouseout(function () {
$("#div" + this).hide();
});
});
});
Run Code Online (Sandbox Code Playgroud)
谢谢.