舒克牙膏图片,19寸桌面壁纸,景凌网zwb9
一、.ascx页面
二、.ascx.cs文件
namespace iocs.web.usercontrol
{
public partial class pagination : system.web.ui.usercontrol
{
public event eventhandler pagebuttonclick;
public bool firstpost = false;
protected void page_load(object sender, eventargs e)
{
if (!ispostback)
{
}
// 只輸入數字
txtpage.attributes.add("onclick",
@"if(!((event.keycode>=48&&event.keycode<=57)
||(event.keycode>=96&&event.keycode<=105)
||(event.keycode==8)))event.returnvalue=false;"
);
}
gridview _gv;
/// <summary>
/// 需要分頁的gridview
/// </summary>
public gridview targetcontrolid
{
set
{
_gv = value;
}
get
{
return _gv;
}
}
protected void pagerbuttonclick(object sender, eventargs e)
{
//獲得linkebutton的參數值
string arg = ((linkbutton)sender).commandargument;
switch (arg)
{
case ("next"):
{
if (_gv.pageindex < _gv.pagecount - 1)
{
_gv.pageindex=_gv.pageindex+1;
}
break;
}
case ("prev"):
{
if (_gv.pageindex > 0)
{
_gv.pageindex--;
}
break;
}
case ("first"):
{
_gv.pageindex = 0;
break;
}
case ("last"):
{
if (_gv.pagecount > 0)
{
_gv.pageindex = _gv.pagecount - 1;
}
break;
}
default:
{
_gv.pageindex = convert.toint32(arg);
break;
}
}
pagebuttonclick(sender, e);
}
public void setpagebutton()
{
if (_gv.pageindex == 0)
{
linkfirst.enabled = false;
linkprevious.enabled = false;
linkfirst.style["color"] = "gray";
linkprevious.style["color"] = "gray";
object s = linkfirst.style.keys;
if (_gv.pagecount > 1)
{
linknext.enabled = true;
linklast.enabled = true;
txtpage.enabled = true;
txtpage.enabled = true;
linknext.style["color"] = "#000";
linklast.style["color"] = "#000";
txtpage.style["readonly"] = "false";
}
else
{
linknext.enabled = false;
linklast.enabled = false;
txtpage.enabled = false;
linknext.style["color"] = "gray";
linklast.style["color"] = "gray";
txtpage.style["readonly"] = "true";//background-color
}
}
else if (_gv.pageindex == _gv.pagecount - 1)
{
linkfirst.enabled = true;
linkprevious.enabled = true;
linknext.enabled = false;
linklast.enabled = false;
linkfirst.style["color"] = "#000";
linkprevious.style["color"] = "#000";
linknext.style["color"] = "gray";
linklast.style["color"] = "gray";
}
else
{
linkfirst.enabled = true;
linkprevious.enabled = true;
linknext.enabled = true;
linklast.enabled = true;
linkfirst.style["color"] = "#000";
linkprevious.style["color"] = "#000";
linknext.style["color"] = "#000";
linklast.style["color"] = "#000";
}
}
/// <summary>
/// 設定頁面信息
/// </summary>
/// <param name="dscount">dataset的紀錄總數</param>
public void setpagerecord(int dscount)
{
lrecords.text = dscount.tostring();
int mod= dscount%_gv.pagesize;
lpages.text = (mod == 0 ? dscount / _gv.pagesize : dscount / _gv.pagesize + 1).tostring();
lpage.text = (_gv.pageindex + 1).tostring();
tbpage.visible = true;
setpagebutton();
}
protected void txtpage_textchanged(object sender, eventargs e)
{
if (txtpage.text != "")
{
try
{
int index = int.parse(txtpage.text.trim());
if (index <= _gv.pagecount && index >= 1)
{
_gv.pageindex = index - 1;
}
else
{
page.clientscript.registerstartupscript(this.gettype(), "script", "<script. language='javascript'>alert('對不起,頁數超過索引范圍!');</script>");
}
}
catch
{
page.clientscript.registerstartupscript(this.gettype(), "script", "<script. language='javascript'>alert('對不起,只能輸入數字!');</script>");
}
}
pagebuttonclick(sender, e);
}
}
}
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Net Core Web Api项目与在NginX下发布的方法
asp.net core3.1 引用的元包dll版本兼容性问题解决方案
IdentityServer4实现.Net Core API接口权限认证(快速入门)
ASP.NET Core MVC通过IViewLocationExpander扩展视图搜索路径的实现
网友评论