I have defined an select on top of my page which shows pageSize(item list pr page)
我在页面顶部定义了一个选择,显示了pageSize(项目列表页面)
<select name="ddlPageSize" style="text-align:left;width:80px;">
@for (var i = 5; i <= 100; i=i+5){
<option>@i</option>
}
</select>
now when i wants to set page size in pagging link like.
现在当我想在pagging链接中设置页面大小时。
<div style="width:inherit; padding:15px 0; clear:both;">
<ul style="text-align:center">
@for (int i = 0; i < (int)Math.Ceiling((decimal)totalCount / (decimal)pageSize); i++)
{
int page = i + 1;
string background = "transparent";//transparent
if (pageNo == page)
{
background = "grey";
}
<li style="display:inline; font-size:14px; color:#000; font-weight:bold; font-family:'VAGRound';padding:0 0px; background-color:@background; ">
<a href="~/Admin/Userspagging?page=@page">@page</a>
</li>
}
</ul>
</div>
in html anchor i wants to pass selected page size too with page Number
在html锚点我想通过页面编号传递选定的页面大小
<a href="~/Admin/Userspagging?page=@page & size=@pageSize">@page</a>
2 个解决方案
#1
1
You will need to change the url on ddlPageSize
selected index change in jQuery.
Here is a link for the same
How to change the href for a hyperlink using jQuery
您需要在jQuery中更改ddlPageSize选定索引更改的URL。这是一个相同的链接如何使用jQuery更改超链接的href
First of all add some class over your anchor
so that you can easily get your Item in jQuery as.
首先在你的锚点上添加一些类,这样你就可以轻松地在jQuery中获取你的Item。
<a class='apager' href="~/Admin/Userspagging?page=@page">@page</a>
and use jquery as below
并使用如下jquery
$("#ddlPageSize" ).on("change", function() {
var selectedValue=$(this).val();
$(".apager").each(function(item,index){
item.attr("href",item.attr("href")+"&pageSize="+selectedValue);
});
});
Note that this is just an idea not implemented so far.
请注意,这只是目前尚未实现的一个想法。
#2
1
If you want to update the anchor link based on user selection, it will have to be done client side.
如果要根据用户选择更新锚链接,则必须在客户端完成。
Also use the data attributes for the URL. You know you will update the URL with just the current page.
还要使用URL的数据属性。您知道只使用当前页面更新URL。
<a id="LINKID" data-url="~/Admin/Userspagging?page=@page" href="">@page</a>
Attach a function to the change event of the dropdown.
将函数附加到下拉列表的更改事件。
$("#ddlPageSize" ).on( "change", function() {
$("#LINKID").attr("href", $("#LINKID").data("id") + "&size=" + $("#ddlPageSize").val())
});
something like that...
类似的东西......
#1
1
You will need to change the url on ddlPageSize
selected index change in jQuery.
Here is a link for the same
How to change the href for a hyperlink using jQuery
您需要在jQuery中更改ddlPageSize选定索引更改的URL。这是一个相同的链接如何使用jQuery更改超链接的href
First of all add some class over your anchor
so that you can easily get your Item in jQuery as.
首先在你的锚点上添加一些类,这样你就可以轻松地在jQuery中获取你的Item。
<a class='apager' href="~/Admin/Userspagging?page=@page">@page</a>
and use jquery as below
并使用如下jquery
$("#ddlPageSize" ).on("change", function() {
var selectedValue=$(this).val();
$(".apager").each(function(item,index){
item.attr("href",item.attr("href")+"&pageSize="+selectedValue);
});
});
Note that this is just an idea not implemented so far.
请注意,这只是目前尚未实现的一个想法。
#2
1
If you want to update the anchor link based on user selection, it will have to be done client side.
如果要根据用户选择更新锚链接,则必须在客户端完成。
Also use the data attributes for the URL. You know you will update the URL with just the current page.
还要使用URL的数据属性。您知道只使用当前页面更新URL。
<a id="LINKID" data-url="~/Admin/Userspagging?page=@page" href="">@page</a>
Attach a function to the change event of the dropdown.
将函数附加到下拉列表的更改事件。
$("#ddlPageSize" ).on( "change", function() {
$("#LINKID").attr("href", $("#LINKID").data("id") + "&size=" + $("#ddlPageSize").val())
});
something like that...
类似的东西......