I have Html.BeginForm , here is its code:
@using (Html.BeginForm()) { @Html.TextBox("searchString", (string)ViewBag.searchString, new { @class = "form-control", name = "searchString", placeholder = "Search..." }) <input type="submit" value="Search" class="btn" /> @Html.ActionLink("Search", "Index", new { sortOrder = @ViewBag.sortOrder, searchString = ???, page = 1 }, new { @class = "btn", type = "submit" }) } By pressing <input type="submit" value="Search" class="btn" /> all parameters are passed correctly, but I need to change one parameter ( page ) to 1, so if I am on page 4 and click the button all parameters will be transferred without changes, then after the search I will be on empty 4 page, and the first will be the search result.
I tried to pass all the parameters using Html.ActionLink , but could not find how to transfer the contents of Html.TextBox as a parameter.
Questions:
- How to change the
pageparameter by clicking thebutton? - How to pass the contents of
Html.TextBoxas a parameter?
<button>and put all your page and sortOrder inHtml.HiddenFor. Read here about the usual pagination , there are no forms. If forms are needed, then either supplement your question, or use the usual button as I wrote HiddenFor +. - AK ♦строка поискаandвариант сортировки. I did this with ViewBag. The problem is that when I am, for example, on page 4 and click on<button>to search, the page is transferred to the controller with all the parameters, and the page does not need to be transferred when searching, or it must be set to1. So I can not figure out how to do it .. - Nikita