Codematic2.0中的PageControl部分源代码 -2

 Source Code of Page02.cs

 

using  System;
using  System.Collections.Generic;
using  System.ComponentModel;
using  System.Text;
using  System.Web;
using  System.Web.UI;
using  System.Web.UI.WebControls;

namespace  Gauss.PageControl
{
    [DefaultProperty(
"Text")]
    [ToolboxData(
"<{0}:Page02 runat=server></{0}:Page02>")]
    
public class Page02 : WebControl
    
{
        
// Fields
        private int page_Count;
        
private int page_Current;
        
private string page_Index;
        
private int page_Size;
        
private int page_width;
        
private int pageStep;

        
public Page02()
        
{
            
this.page_Size = 10;
            
this.page_Current = 1;
            
this.page_Index = "index.aspx";
            
this.pageStep = 6;
            
this.page_width = 700;
        }

        
public int Page_Count
        
{
            
get
            
{
                
return this.page_Count;
            }

            
set
            
{
                
this.page_Count = value;
            }

        }

        
public int Page_Current
        
{
            
get
            
{
                
return this.page_Current;
            }

            
set
            
{
                
this.page_Current = value;
            }

        }


        
public string Page_Index
        
{
            
get
            
{
                
return this.page_Index;
            }

            
set
            
{
                
this.page_Index = value;
            }

        }


        
public int Page_Size
        
{
            
get
            
{
                
return this.page_Size;
            }

            
set
            
{
                
this.page_Size = value;
            }

        }


        [Bindable(
true), DefaultValue(""), Category("Appearance")]
        
public int Page_Width
        
{
            
get
            
{
                
return this.page_width;
            }

            
set
            
{
                
this.page_width = value;
            }

        }


        
public int PageStep
        
{
            
get
            
{
                
return this.pageStep;
            }

            
set
            
{
                
this.pageStep = value;
            }

        }


        
protected override void Render(HtmlTextWriter output)
        
{
            StringBuilder builder1 
= new StringBuilder("");
            builder1.Append(
"<table width="" + this.page_width + "" border="0" cellspacing="0" cellpadding="0" align="center" height="22"> ");
            builder1.Append(
" <tr> ");
            builder1.Append(
" <td width="171">");
            builder1.Append(
string.Concat(new object[] "○ 页次:<font color="#e78a29">"this.Page_Current, "</font>/"this.Page_Count, ",每页:<font color='#e78a29'>"this.Page_Size, "</font>条</td> " }));
            builder1.Append(
" <td width="529"> ");
            builder1.Append(
" <div align="right">页数: ");
            
int num1 = 1;
            
if (this.Page_Current > this.PageStep)
            
{
                num1 
= this.Page_Current - this.PageStep;
            }

            
else
            
{
                num1 
= 1;
            }

            
int num2 = num1 + (2 * this.PageStep);
            
if ((num1 + (2 * this.PageStep)) > this.Page_Count)
            
{
                
if (((2 * this.PageStep) + 1> this.Page_Count)
                
{
                    num1 
= 1;
                }

                
else
                
{
                    num1 
= this.Page_Count - (2 * this.PageStep);
                }

                num2 
= this.Page_Count;
            }

            
for (int num3 = num1; num3 <= num2; num3++)
            
{
                
if (this.Page_Current != num3)
                
{
                    builder1.Append(
string.Concat(new object[] " <a href="this.Page_Index, "?page=", num3, ">" }));
                    builder1.Append(
"[<b>" + num3 + "</b>]</a>");
                }

                
else
                
{
                    builder1.Append(
" [<font color=#e78a29><b>" + num3 + "</b></font>]");
                }

            }

            builder1.Append(
" </div> ");
            builder1.Append(
" </td> ");
            builder1.Append(
" </tr> ");
            builder1.Append(
"</table>");
            output.Write(builder1.ToString());
        }



    }

}

Source Code of Page03.cs

 

using  System;
using  System.Collections.Generic;
using  System.ComponentModel;
using  System.Text;
using  System.Web;
using  System.Web.UI;
using  System.Web.UI.WebControls;

namespace  Gauss.PageControl
{
    [DefaultProperty(
"Text")]
    [ToolboxData(
"<{0}:Page03 runat=server></{0}:Page03>")]
    
public class Page03 : WebControl
    
{
        
// Fields
        private int page_Count;
        
private int page_Current;
        
private string page_Index;
        
private int page_Size;
        
private int page_width;
        
private int pageStep;
        
private int record_Count;

        
public Page03()
        
{
            
this.page_Size = 10;
            
this.page_Current = 1;
            
this.page_Index = "index.aspx";
            
this.pageStep = 6;
            
this.page_width = 700;
        }

        
public int Page_Count
        
{
            
get
            
{
                
return this.page_Count;
            }

            
set
            
{
                
this.page_Count = value;
            }

        }


        
public int Page_Current
        
{
            
get
            
{
                
return this.page_Current;
            }

            
set
            
{
                
this.page_Current = value;
            }

        }


        
public string Page_Index
        
{
            
get
            
{
                
return this.page_Index;
            }

            
set
            
{
                
this.page_Index = value;
            }

        }


        
public int Page_Size
        
{
            
get
            
{
                
return this.page_Size;
            }

            
set
            
{
                
this.page_Size = value;
            }

        }


        [DefaultValue(
""), Bindable(true), Category("Appearance")]
        
public int Page_Width
        
{
            
get
            
{
                
return this.page_width;
            }

            
set
            
{
                
this.page_width = value;
            }

        }


        
public int PageStep
        
{
            
get
            
{
                
return this.pageStep;
            }

            
set
            
{
                
this.pageStep = value;
            }

        }


        
public int Record_Count
        
{
            
get
            
{
                
return this.record_Count;
            }

            
set
            
{
                
this.record_Count = value;
            }

        }

 


        
protected override void Render(HtmlTextWriter output)
        
{
            StringBuilder builder1 
= new StringBuilder("");
            builder1.Append(
"<table width="" + this.page_width + "" border="0" cellspacing="0" cellpadding="0" align="center" height="22"> ");
            builder1.Append(
" <tr> ");
            builder1.Append(
" <td width="255">");
            builder1.Append(
string.Concat(new object[] "○ 页次:<font color="#e78a29">"this.Page_Current, "</font>/"this.Page_Count, ",每页:<font color='#e78a29'>"this.Page_Size, "</font>条" }));
            builder1.Append(
",共计:<font color='#e78a29'>" + this.Record_Count + "</font>条");
            builder1.Append(
"</td> ");
            builder1.Append(
" <td width="*"> ");
            builder1.Append(
" <div align="right">页数: ");
            
int num1 = 1;
            
if (this.Page_Current > this.PageStep)
            
{
                num1 
= this.Page_Current - this.PageStep;
            }

            
else
            
{
                num1 
= 1;
            }

            
int num2 = num1 + (2 * this.PageStep);
            
if ((num1 + (2 * this.PageStep)) > this.Page_Count)
            
{
                
if (((2 * this.PageStep) + 1> this.Page_Count)
                
{
                    num1 
= 1;
                }

                
else
                
{
                    num1 
= this.Page_Count - (2 * this.PageStep);
                }

                num2 
= this.Page_Count;
            }

            
for (int num3 = num1; num3 <= num2; num3++)
            
{
                
if (this.Page_Current != num3)
                
{
                    builder1.Append(
string.Concat(new object[] " <a href="this.Page_Index, "?page=", num3, ">" }));
                    builder1.Append(
"[<b>" + num3 + "</b>]</a>");
                }

                
else
                
{
                    builder1.Append(
" [<font color=#e78a29><b>" + num3 + "</b></font>]");
                }

            }

            builder1.Append(
" </div> ");
            builder1.Append(
" </td> ");
            builder1.Append(
" </tr> ");
            builder1.Append(
"</table>");
            output.Write(builder1.ToString());
        }



    }

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值