Layout.cshtml上的ASP.NET MVC搜索框

Rob*_*lls 5 asp.net-mvc

我已经从http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-创建了搜索表单和结果一个在ASP.NET MVC 应用程序中的框架,该应用程序使用PagedList Nuget包处理分页和排序。

我需要帮助的是如何将搜索表单放在主页上?(_layout.cshtml)?

Nad*_*edr 5

放置一个from包含一个文本框和一个按钮,表单的动作将是搜索动作

_layout.cshtml页面中的防爆码

@using(Html.BeginForm("ActionName","ControllerName", FormMethod.Get))
{
    @Html.TextBoxFor(m => m.Query)

    <div>
        <input type="submit" value="Search" />
    </div>
}
Run Code Online (Sandbox Code Playgroud)