using System;
System.Collections.Generic を使用;
System.ComponentModel を使用します。
System.Linq を使用;
System.Text を使用;
System.Web を使用;
System.Web.UI を使用;
System.Web.UI.WebControls を使用します。
System.Reflection を使用します。
System.IO を使用;
[アセンブリ: WebResource("PageBarJS.js", "application/x-javascript")]
namespace Hawkon.Control {
[DefaultProperty("Text")]
[ToolboxData("< ;{0}:PageBar runat=server>{0}:PageBar>")]
public class PageBar : WebControl {
[Bindable(true)]
[Category("Data") ]
[DefaultValue("1")]
[Localizable(true)]
public int PageIndex {
get {
return pageIndex;
}
set {
pageIndex = 値;
}
}
private int pageIndex;
[Bindable(true)]
[Category("Data")]
[DefaultValue("1")]
[Localizable(true)]
public int PageCount {
get {
return pageCount;
}
set {
pageCount = 値;
}
}
private int pageCount;
[Bindable(true)]
[Category("Data")]
[DefaultValue("5")]
[Localizable(true)]
public int DisplayCount {
get {
return displayCount;
}
set {
displayCount = 値;
}
}
private int displayCount;
protected override void RenderContents(HtmlTextWriter 出力) {
string html = "";
html = CreateA(1, "<<");
int b = 0、e = 0;
if (pageIndex <= displayCount) {
b = 1;
e = 表示カウント * 2 1;
}
else if (pageIndex > pageCount - displayCount) {
b = pageCount - displayCount * 2;
e = ページ数;
}
else {
b = pageIndex - displayCount;
e = pageIndex displayCount;
}
if (b <= 1) {
html = CreateA(1, "");
}
else
html = CreateA(b - 1, "");
for (int i = b; i <= e; i ) {
html = CreateA(i, i.ToString());
}
html = CreateA(e 1, "");
html = CreateA(pageCount, ">>");
// html = string.Format("",
// this.Page.ClientScript.GetWebResourceUrl (typeof(PageBar), "JScript1.js"));
output.Write(html);
}
private string CreateA(int pageIndex, string text) {
if (pageIndex == this.pageIndex) {
return string.Format("
{1} "、pageIndex、text);
}
return string.Format("
{1} ",ページインデックス、テキスト);
}
protected override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
文字列リソース名 = "PageBarJS.js";
文字列 url = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "PageBarJS.js");
string script = "rn";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), resourceName, script, false);
script = @""; this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "準備完了", script);
}
protected override void Render(HtmlTextWriter Writer) {
base.Render(writer);
}
}
}