A
A
addd2015-12-01 11:05:41
ASP.NET
addd, 2015-12-01 11:05:41

How to do proper paging with Ajax.BeginForm?

@using (Ajax.BeginForm(MVC.Сar.GetPartialView(size, page), new AjaxOptions { UpdateTargetId = "update_grid"}))
        {
        }

....
<a href="#">@i</a> //здесь в циклt выводятся страницы по порядку - 1 2 3 ....

-how to call ajax.beginform when clicking on a link
-how to pass the value from @i to the page parameter

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kovalsky, 2015-12-01
@addd

Suppose your request is waiting for a page number to be returned.
The simplest and most banal is to make a hidden field with the page number.
And to links to hang up the following handler.

<script>
function GetPage(var page)
{
$("#селектор скрытого поля, хранящий номер страницы").val(page);
$("#идентификатор формы").submit();
return false;
}
</script>
<a href="#" onclick=GetPage(@i)>@i</

This is what is called a decision in the forehead. Very rough.
PS Do not forget that there can be many pages. The "classic" pager is 3-5 links in the visibility zone + "To the beginning" and "To the end".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question