HTML

 <input type="text" id="keyword" name="keyword" autocomplete="off" onkeydown="javascript:if(event.keyCode==13) search(document.getElementById('keyword').value);" value="@WorkContext.SearchWord" />
View Code

JS

//搜索
function search(keyword) {
    if (keyword == undefined || keyword == null || keyword.length < 1) {
        alert("请输入关键词");
    }
    else {
        window.location.href = "/Catalog/Search?keyword=" + encodeURIComponent(keyword);
    }
}
View Code

路由

  //搜索路由
            routes.MapRoute("Search",
                            "search",
                            new { controller = "Catalog", action = "Search" },
                            new[] { "BrnShop.Web.Controllers" });
View Code

 

posted on 2014-10-09 14:45  随心所意  阅读(196)  评论(0编辑  收藏  举报