I have cshtml view page with paginations
here view of that page
Once I click any of below number (which is 1 to 10) I should be able to pass that number to POST method of that form
this is the relevant cshtml code snippet to that pagination
@if (Model.Pager.EndPage > 1)
{
<ul class="pagination">
@for (var page = Model.Pager.StartPage; page <= Model.Pager.EndPage; page++)
{
<li class="@(page == Model.Pager.CurrentPage ? "active" : "")">
<input type="submit" value=@page class="btn btn-default" ViewBag.pagenumber=@page/>
</li>
}
</ul>
}
then I try to pass that value like this
@using (Html.BeginForm("method_name", "controller", new { pagenumber = ViewBag.pagenumber} , FormMethod.Post))
{
but pagenumber
getting null each time, in this way
EDIT:
[HttpGet]
public ActionResult method_name(int? page,string Product_ID)
{
........
}
[HttpPost]
[ValidateInput(false)]
public ActionResult method_name(AddNewProduct product, string pagenumber)
{
.....
return RedirectToAction("method_name", "controller", new { page = pagenumber});
}