小编vob*_*obs的帖子

在ASP.NET MVC中搜索路径

我的母版页中有一个简单的搜索表单和一个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".

谢谢.

asp.net asp.net-mvc search action routes

7
推荐指数
1
解决办法
1456
查看次数

使用jquery每个在悬停时显示/隐藏

我和班级"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)

谢谢.

each jquery onmouseover

0
推荐指数
1
解决办法
4307
查看次数

标签 统计

action ×1

asp.net ×1

asp.net-mvc ×1

each ×1

jquery ×1

onmouseover ×1

routes ×1

search ×1