|
|
|
@ -4,6 +4,7 @@ using System.Security.Permissions;
|
|
|
|
using System.Web.UI;
|
|
|
|
using System.Web.UI;
|
|
|
|
using System.Web.UI.WebControls;
|
|
|
|
using System.Web.UI.WebControls;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Yavsc.WebControls
|
|
|
|
namespace Yavsc.WebControls
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -29,19 +30,16 @@ namespace Yavsc.WebControls
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the results per page.
|
|
|
|
/// Gets or sets the results per page.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The results per page.</value>
|
|
|
|
/// <value>The results per page.</value>
|
|
|
|
[Bindable (true)]
|
|
|
|
public int PageSize {
|
|
|
|
[DefaultValue(10)]
|
|
|
|
|
|
|
|
public int ResultsPerPage {
|
|
|
|
|
|
|
|
get {
|
|
|
|
get {
|
|
|
|
return (int)( ViewState["ResultsPerPage"]==null?10:ViewState["ResultsPerPage"]);
|
|
|
|
return (int)( ViewState["PageSize"]==null?10:ViewState["PageSize"]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
set {
|
|
|
|
ViewState["ResultsPerPage"]=value;
|
|
|
|
ViewState["PageSize"]=value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -50,11 +48,8 @@ namespace Yavsc.WebControls
|
|
|
|
/// Gets or sets the result count.
|
|
|
|
/// Gets or sets the result count.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The result count.</value>
|
|
|
|
/// <value>The result count.</value>
|
|
|
|
[Bindable (true)]
|
|
|
|
|
|
|
|
[DefaultValue(0)]
|
|
|
|
|
|
|
|
public int ResultCount {
|
|
|
|
public int ResultCount {
|
|
|
|
get {
|
|
|
|
get {
|
|
|
|
|
|
|
|
|
|
|
|
return (int)( ViewState["ResultCount"]==null?0:ViewState["ResultCount"]);
|
|
|
|
return (int)( ViewState["ResultCount"]==null?0:ViewState["ResultCount"]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
set {
|
|
|
|
@ -66,7 +61,6 @@ namespace Yavsc.WebControls
|
|
|
|
/// Gets or sets the text.
|
|
|
|
/// Gets or sets the text.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The text.</value>
|
|
|
|
/// <value>The text.</value>
|
|
|
|
[Bindable (true)]
|
|
|
|
|
|
|
|
[DefaultValue("Pages:")]
|
|
|
|
[DefaultValue("Pages:")]
|
|
|
|
[Localizable(true)]
|
|
|
|
[Localizable(true)]
|
|
|
|
public string Text {
|
|
|
|
public string Text {
|
|
|
|
@ -85,25 +79,27 @@ namespace Yavsc.WebControls
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The action.</value>
|
|
|
|
/// <value>The action.</value>
|
|
|
|
[Bindable (true)]
|
|
|
|
[Bindable (true)]
|
|
|
|
[DefaultValue("")]
|
|
|
|
[DefaultValue("?pageIndex=")]
|
|
|
|
public string Action {
|
|
|
|
public string Action {
|
|
|
|
get {
|
|
|
|
get {
|
|
|
|
|
|
|
|
|
|
|
|
string s = (string)ViewState["Action"];
|
|
|
|
string s = (string)ViewState["Action"];
|
|
|
|
return (s == null) ? String.Empty : s;
|
|
|
|
return (s == null) ? "?pageIndex=" : s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
set {
|
|
|
|
ViewState["Action"] = value;
|
|
|
|
ViewState["Action"] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// Gets or sets the none.
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <value>The none.</value>
|
|
|
|
[Bindable (true)]
|
|
|
|
[Bindable (true)]
|
|
|
|
[DefaultValue("none")]
|
|
|
|
[DefaultValue("none")]
|
|
|
|
public string None {
|
|
|
|
public string None {
|
|
|
|
get {
|
|
|
|
get {
|
|
|
|
|
|
|
|
return (string) ViewState["None"];
|
|
|
|
string s = (string) ViewState["None"];
|
|
|
|
|
|
|
|
return (s == null) ? String.Empty : s;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
set {
|
|
|
|
ViewState["None"] = value;
|
|
|
|
ViewState["None"] = value;
|
|
|
|
@ -116,41 +112,42 @@ namespace Yavsc.WebControls
|
|
|
|
/// <value>The current page.</value>
|
|
|
|
/// <value>The current page.</value>
|
|
|
|
[Bindable (true)]
|
|
|
|
[Bindable (true)]
|
|
|
|
[DefaultValue(0)]
|
|
|
|
[DefaultValue(0)]
|
|
|
|
public int CurrentPage {
|
|
|
|
public int PageIndex {
|
|
|
|
get {
|
|
|
|
get {
|
|
|
|
int i = (int)(ViewState["CurrentPage"]==null?0:ViewState["CurrentPage"]);
|
|
|
|
int i = (int)(ViewState["PageIndex"]==null?0:ViewState["PageIndex"]);
|
|
|
|
return i;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
set {
|
|
|
|
ViewState["CurrentPage"] = value;
|
|
|
|
ViewState["PageIndex"] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Renders the contents as the list of links to pages of results.
|
|
|
|
/// Renders the contents as the list of links to pages of results.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="writer">Writer.</param>
|
|
|
|
/// <param name="writer">Writer.</param>
|
|
|
|
protected override void RenderContents (HtmlTextWriter writer)
|
|
|
|
protected override void RenderContents (HtmlTextWriter writer)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (ResultCount > 0 && ResultCount > ResultsPerPage ) {
|
|
|
|
if (ResultCount > 0 && ResultCount > PageSize ) {
|
|
|
|
writer.WriteEncodedText (Text);
|
|
|
|
writer.WriteEncodedText (Text);
|
|
|
|
int pageCount = ((ResultCount-1) / ResultsPerPage) + 1;
|
|
|
|
int pageCount = ((ResultCount-1) / PageSize) + 1;
|
|
|
|
for (int pi = (CurrentPage < 5) ? 0 : CurrentPage - 5; pi < pageCount && pi < CurrentPage + 5; pi++) {
|
|
|
|
if ( pageCount > 1 ) {
|
|
|
|
if (CurrentPage == pi)
|
|
|
|
for (int pi = (PageIndex < 5) ? 0 : PageIndex - 5; pi < pageCount && pi < PageIndex + 5; pi++) {
|
|
|
|
|
|
|
|
if (PageIndex == pi)
|
|
|
|
writer.RenderBeginTag ("b");
|
|
|
|
writer.RenderBeginTag ("b");
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
writer.AddAttribute (HtmlTextWriterAttribute.Href,
|
|
|
|
writer.AddAttribute (HtmlTextWriterAttribute.Href,
|
|
|
|
string.Format (Action, pi));
|
|
|
|
string.Format (Action, pi));
|
|
|
|
writer.RenderBeginTag ("a");
|
|
|
|
writer.RenderBeginTag ("a");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
writer.Write (pi+1);
|
|
|
|
writer.Write (pi + 1);
|
|
|
|
writer.RenderEndTag ();
|
|
|
|
writer.RenderEndTag ();
|
|
|
|
writer.Write (" ");
|
|
|
|
writer.Write (" ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if (ResultCount == 0) {
|
|
|
|
if (ResultCount == 0) {
|
|
|
|
writer.Write ("(");
|
|
|
|
|
|
|
|
writer.Write (None);
|
|
|
|
writer.Write (None);
|
|
|
|
writer.Write (")");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|