欧美日韩一区二区三区四区不卡,日韩欧美视频一区二区三区四区,久久精品欧美一区二区三区不卡,国产精品久久久乱弄

咨詢電話:186 7916 6165 咨詢電話:186 7916 6165 (微信同號)    在線QQ:181796286
NEWS BLOG ·
學無止境
關注開優網絡 關注前沿
ASP.NET實現登錄成功后返回請求頁
ASP.NET在后臺直接驗證表單數據

AspNetPager自定義使用方法

發表日期:2019-01-05    文章編輯:    瀏覽次數:3945    標簽:

<webdiyer:AspNetPager ID="anp" runat="server"
    CssClass="pages" CurrentPageButtonClass="cpb"
    CustomInfoHTML="總共%RecordCount%條記錄,當前為%CurrentPageIndex%/%PageCount%頁"
    FirstPageText="首頁" LastPageText="尾頁" NextPageText="下一頁"
    NumericButtonCount="5"
    OnPageChanged="anp_PageChanged"
    PageIndexBoxType="TextBox"
    PrevPageText="上一頁" ShowDisabledButtons="false" ShowFirstLast="false" ShowPageIndex="false" ShowPrevNext="false" ShowNavigationToolTip="false" ShowMoreButtons="False" ShowPageIndexBox="Never"
    SubmitButtonText="Go" TextAfterPageIndexBox="頁" TextBeforePageIndexBox="轉到" PageSize="1">
</webdiyer:AspNetPager>

ShowDisabledButtons 是否顯示禁用按鈕
ShowFirstLast    是否顯示首頁和尾頁
ShowPrevNext    是否顯示上一頁和下一頁
ShowPageIndex    是否顯示數字按鈕

//數字跳轉
<div class="pagelist">
     <asp:TextBox ID="tb_pageindex" runat="server" Width="60px" Text="8"></asp:TextBox> //數值文本框
     <asp:Button ID="Button1" runat="server" Text="轉到" OnClick="Button1_Click" /> 按鈕事件
     <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Text="必須輸入頁索引" ControlToValidate="tb_pageindex"/><asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="tb_pageindex" Operator="DataTypeCheck" Type="Integer" Text="頁索引必須是整數"/> //驗證tb_pageindex數值文本框
     <asp:Label ID="lbl_error" runat="server" ForeColor="Red" EnableViewState="false"></asp:Label> //錯誤是顯示的信息    
</div>

//后臺事件
protected void Button1_Click(object sender, EventArgs e)
{
    try
    {
        int pageindex = int.Parse(tb_pageindex.Text); //獲取數值文本框值
        anp.GoToPage(pageindex); //跳轉到相應的頁數
    }
    catch (FormatException)
    {
        lbl_error.Text = "輸入的頁索引格式不正確";
    }
}

//只顯示下一頁 一個按鈕
<div class="pagelist">
     <asp:Button ID="Button2" runat="server" Text="下一頁" OnClick="Button2_Click" />    
</div>

protected void Button2_Click(object sender, EventArgs e)
{
    try
    {
        if (anp.RecordCount<anp.CurrentPageIndex+1)  //總記錄數小于當前頁數+1
        {
            Xiaobin.Utility.Tool.Alert("已是最后一頁",this.Page);
            return;
        }        
        anp.GoToPage(anp.CurrentPageIndex + 1); //跳轉到當前頁數+1,即下一頁
    }
    catch (FormatException)
    {
        Xiaobin.Utility.Tool.Alert("參數錯誤!",this.Page);      
    }
}
主站蜘蛛池模板: 桐柏县| 鸡西市| 汉川市| 越西县| 垣曲县| 白城市| 盖州市| 松原市| 称多县| 镇坪县| 舒城县| 双江| 桂平市| 杭州市| 沽源县| 沧源| 光山县| 探索| 睢宁县| 施甸县| 武山县| 石城县| 蓬溪县| 新绛县| 汨罗市| 开江县| 洛扎县| 柞水县| 堆龙德庆县| 武冈市| 汤原县| 海宁市| 正定县| 浮山县| 内丘县| 于都县| 鸡泽县| 盐源县| 枞阳县| 芒康县| 宁南县|