惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Security Affairs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
P
Palo Alto Networks Blog
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale
S
Schneier on Security
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
雷峰网
雷峰网
T
Tenable Blog
人人都是产品经理
人人都是产品经理
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
AWS News Blog
AWS News Blog
Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
Scott Helme
Scott Helme
SecWiki News
SecWiki News
C
CERT Recently Published Vulnerability Notes
Recorded Future
Recorded Future
I
InfoQ
Security Archives - TechRepublic
Security Archives - TechRepublic
Help Net Security
Help Net Security
Cloudbric
Cloudbric
C
Check Point Blog
Engineering at Meta
Engineering at Meta
TaoSecurity Blog
TaoSecurity Blog
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
N
News and Events Feed by Topic
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
腾讯CDC
量子位
Application and Cybersecurity Blog
Application and Cybersecurity Blog
K
Kaspersky official blog
Vercel News
Vercel News
F
Full Disclosure
T
Troy Hunt's Blog
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs

博客园 - venjiang

发布Asp.Net Forums V2.2.1929 官方中文Beta版 转换DotNetNuke为C#版 Asp.Net Forums 2.0.1 内部开发版系统文件说明 发布Asp.Net Forums V2 中文官方 10.1 国庆版 asp.net forums2 本地化版本0831发布(开源) Asp.Net Forums2 本地化工作记录0831 获取的本地区域为何不变?搞得我头都大了! Asp.Net Forums2组件库简要说明 [转贴]IIS6.0服务器无法访问解决方案总结 测试你的Blog价值 Data Access Application Block V2 类库中文文档 Data Access Application Block 3.1 博客园LOGO[修改版] DotNet开发人员现在应该下载的十种必备工具下载说明 模拟Asp.Net Forums 2.0 数据提供者类 Caching ASP.NET pages 卸载Windows Messenger 和高手过招 解决Automation 服务器不能创建对象
[Asp.Net Forums 2.0]增加Pager控件没有的跳转页功能
venjiang · 2004-07-07 · via 博客园 - venjiang

增加Pager控件没有的跳转页功能

作者: venjiang    2004年6月14日

Pager类,用于分页, Controls\Utility\Pager.cs

首先增加成员变量:

        /// venjiang:增加跳转页输入文本框

        /// </summary>

        TextBox gotoPage;

        /// <summary>

        /// venjiang:增加跳转按钮

        /// </summary>

        LinkButton gotoButton;

其次增加控件:

/// <summary>

        /// 跳转按钮

        /// </summary>

        void AddGotoButton()

        {

            this.gotoButton=new LinkButton();

            this.gotoButton.ID="GoTo";

            this.gotoButton.Text="Go";

            this.gotoButton.Click += new System.EventHandler(PageIndex_Click);

            Controls.Add(gotoButton);

        }

        /// <summary>

        /// 增加跳转页输入框

        /// </summary>

        void AddGotoPage()

        {

            this.gotoPage=new TextBox();

            this.gotoPage.Width=30;

            this.gotoPage.ID="GoToPage";

            //this.gotoPage.Text="3";

            this.gotoPage.TextChanged += new System.EventHandler(PageText_Change);

            //this.gotoPage.EnableViewState=true;

            Controls.Add(gotoPage);

        }

增加跳转页文本框文本改变事件:

    void PageText_Change(Object sender,EventArgs e)

        {

            int i = 1;

            try

            {

                i = Convert.ToInt32(this.gotoPage.Text.Trim().ToString());

                if(i < 1)

                {

                    i = 1;

                    this.gotoPage.Text="1";

                }

                if(i > CalculateTotalPages())

                {

                    i = CalculateTotalPages();

                    this.gotoPage.Text=i.ToString();

                }

            }

            catch

            {

                this.gotoPage.Text="";

                return;

            }

            this.gotoButton.CommandArgument = (i-1).ToString();

        }

增加呈现方法:

        void RenderGotoPage(HtmlTextWriter writer)

        {

            Literal l,m;

            l = new Literal();

            l.Text = "&nbsp;&nbsp;";

            l.RenderControl(writer);

            this.gotoPage.RenderControl(writer);

            this.gotoButton.RenderControl(writer);

            m = new Literal();

            m.Text = "&nbsp;";

            m.RenderControl(writer);

        }

最后将所创建的方法分别添加到相应用方法中:

CreateChildControls()方法尾部,增加this.AddGotoPage();this.AddGotoButton();

Render()方法尾部,增加this.RenderGotoPage(writer);

重新运行程序,分页图如下: