5

I've created the search form and results from http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application which handles paging and sorting using the PagedList Nuget package.

What I need help with though, is how do I put the search form on my master page? (_layout.cshtml)?

4

1 に答える 1

6

put a from contains a Text box and a button and the form's action will be the search action

Ex code in the _layout.cshtml page

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

    <div>
        <input type="submit" value="Search" />
    </div>
}
于 2012-04-22T08:16:04.933 に答える