Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs/class
diff options
context:
space:
mode:
authorMarek Habersack <grendel@twistedcode.net>2010-06-19 03:02:03 +0400
committerMarek Habersack <grendel@twistedcode.net>2010-06-19 03:02:03 +0400
commit5e585590bbf5d7c05497b948556becf277719d21 (patch)
tree14b51aa3a8a42a0bbe679c94e4225d3cdf58c15d /mcs/class
parentd2fb350f157e96a0871de23b452a573a835dd2bb (diff)
Backport of r159161
svn path=/branches/mono-2-6/mcs/; revision=159162
Diffstat (limited to 'mcs/class')
-rw-r--r--mcs/class/System.Web.Extensions/System.Web.UI.WebControls/ChangeLog13
-rw-r--r--mcs/class/System.Web.Extensions/System.Web.UI.WebControls/DataPager.cs5
-rw-r--r--mcs/class/System.Web.Extensions/System.Web.UI.WebControls/DataPagerField.cs2
-rw-r--r--mcs/class/System.Web.Extensions/System.Web.UI.WebControls/NumericPagerField.cs97
4 files changed, 70 insertions, 47 deletions
diff --git a/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/ChangeLog b/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/ChangeLog
index 9b7ab8f1aca..fa370c9af0b 100644
--- a/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/ChangeLog
+++ b/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/ChangeLog
@@ -1,3 +1,16 @@
+2010-06-19 Marek Habersack <mhabersack@novell.com>
+
+ * DataPager.cs: when rendering the ID attribute, use ClientID
+
+2010-06-18 Marek Habersack <mhabersack@novell.com>
+
+ * NumericPagerField.cs: CreateDataPagers outputs correct page
+ number in query mode. Fixes bug #615315
+ Rendering changes to match .NET
+
+ * DataPagerField.cs: if query string has been handled and query
+ mode is in effect, return true. Fixes bug #615315
+
2010-05-18 Marek Habersack <mhabersack@novell.com>
* ListView.cs: if data source has pageable data, get total count
diff --git a/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/DataPager.cs b/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/DataPager.cs
index b00c2868a58..b04ed277542 100644
--- a/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/DataPager.cs
+++ b/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/DataPager.cs
@@ -4,7 +4,7 @@
// Authors:
// Marek Habersack (mhabersack@novell.com)
//
-// (C) 2007-2008 Novell, Inc
+// (C) 2007-2010 Novell, Inc
//
//
@@ -86,7 +86,7 @@ namespace System.Web.UI.WebControls
protected virtual void AddAttributesToRender (HtmlTextWriter writer)
{
if (ID != null)
- writer.AddAttribute (HtmlTextWriterAttribute.Id, ID);
+ writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID);
if (_attributes != null && _attributes.Count > 0) {
foreach (string attr in _attributes.Keys)
@@ -257,7 +257,6 @@ namespace System.Web.UI.WebControls
protected internal override void OnInit (EventArgs e)
{
base.OnInit (e);
-
Page page = Page;
if (page != null)
page.RegisterRequiresControlState (this);
diff --git a/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/DataPagerField.cs b/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/DataPagerField.cs
index ae33559ecbf..9ae3e9fd767 100644
--- a/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/DataPagerField.cs
+++ b/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/DataPagerField.cs
@@ -210,7 +210,7 @@ namespace System.Web.UI.WebControls
{
bool queryMode = !String.IsNullOrEmpty (DataPager.QueryStringField);
if (!queryMode || QueryStringHandled)
- return false;
+ return queryMode;
QueryStringHandled = true;
diff --git a/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/NumericPagerField.cs b/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/NumericPagerField.cs
index f16b063bb97..6cf9951821a 100644
--- a/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/NumericPagerField.cs
+++ b/mcs/class/System.Web.Extensions/System.Web.UI.WebControls/NumericPagerField.cs
@@ -4,7 +4,7 @@
// Authors:
// Marek Habersack (mhabersack@novell.com)
//
-// (C) 2007-2008 Novell, Inc
+// (C) 2007-2010 Novell, Inc
//
//
@@ -84,65 +84,69 @@ namespace System.Web.UI.WebControls
bool queryMode = GetQueryModeStartRowIndex (_totalRowCount, _maximumRows, ref _startRowIndex, ref setPagePropertiesNeeded);
bool addNonBreakingSpace = RenderNonBreakingSpacesBetweenControls;
int buttonCount = ButtonCount;
-
int totalPages = totalRowCount / maximumRows + (totalRowCount % maximumRows > 0 ? 1 : 0);
int currentPage = startRowIndex == 0 ? 1 : (startRowIndex / maximumRows) + 1;
- int firstPage = ((startRowIndex / (maximumRows * buttonCount)) * buttonCount) + 1;
- int lastPage = firstPage + buttonCount - 1;
+ int activePage = ((startRowIndex / (maximumRows * buttonCount)) * buttonCount) + 1;
+ int lastPage = activePage + buttonCount - 1;
- bool showPreviousPage = firstPage > buttonCount;
- bool showNextPage = totalPages - firstPage >= buttonCount;
+ bool showPreviousPage = activePage > buttonCount;
+ bool showNextPage = totalPages - activePage >= buttonCount;
if (lastPage > totalPages)
lastPage = totalPages;
- int newPageNum = -1;
+ int newPageNum;
if (showPreviousPage) {
- if (queryMode)
- newPageNum = (_startRowIndex / _maximumRows) - 1;
-
+ newPageNum = activePage - 1;
+ if (newPageNum < 1)
+ newPageNum = 1;
+
CreateButton (container, DataControlCommands.PreviousPageCommandArgument, PreviousPageText, PreviousPageImageUrl,
- NextPreviousButtonCssClass, newPageNum, queryMode, true, addNonBreakingSpace);
+ NextPreviousButtonCssClass, newPageNum, queryMode, true, addNonBreakingSpace, false);
}
string numericButtonCssClass = NumericButtonCssClass;
bool enabled;
string pageString;
- while (firstPage <= lastPage) {
- enabled = firstPage != currentPage;
- pageString = firstPage.ToString (CultureInfo.InvariantCulture);
+ while (activePage <= lastPage) {
+ enabled = activePage != currentPage;
+ pageString = activePage.ToString (CultureInfo.InvariantCulture);
CreateButton (container, pageString, pageString, String.Empty,
- enabled ? numericButtonCssClass : CurrentPageLabelCssClass, firstPage,
- queryMode, enabled, addNonBreakingSpace);
- firstPage++;
+ enabled ? numericButtonCssClass : CurrentPageLabelCssClass, activePage,
+ queryMode, enabled, addNonBreakingSpace, true);
+ activePage++;
}
+ if (showNextPage && addNonBreakingSpace)
+ container.Controls.Add (new LiteralControl ("&nbsp;"));
- if (showNextPage) {
- if (queryMode)
- newPageNum = (_startRowIndex + _maximumRows) / _maximumRows;
-
+ if (showNextPage)
CreateButton (container, DataControlCommands.NextPageCommandArgument, NextPageText, NextPageImageUrl,
- NextPreviousButtonCssClass, newPageNum, queryMode, true, addNonBreakingSpace);
- }
+ NextPreviousButtonCssClass, activePage, queryMode, true, addNonBreakingSpace, false);
if (setPagePropertiesNeeded)
DataPager.SetPageProperties (_startRowIndex, _maximumRows, true);
}
void CreateButton (DataPagerFieldItem container, string commandName, string text, string imageUrl, string cssClass, int pageNum,
- bool queryMode, bool enabled, bool addNonBreakingSpace)
+ bool queryMode, bool enabled, bool addNonBreakingSpace, bool isPageNumber)
{
WebControl ctl = null;
if (queryMode) {
- pageNum++;
- HyperLink h = new HyperLink ();
- h.Text = text;
- h.ImageUrl = imageUrl;
- h.Enabled = enabled;
- h.NavigateUrl = GetQueryStringNavigateUrl (pageNum);
- h.CssClass = cssClass;
- ctl = h;
+ if (isPageNumber && !enabled) {
+ var span = new Label ();
+ span.Text = text;
+ span.CssClass = cssClass;
+ ctl = span;
+ } else {
+ HyperLink h = new HyperLink ();
+ h.Text = text;
+ h.ImageUrl = imageUrl;
+ h.Enabled = enabled;
+ h.NavigateUrl = GetQueryStringNavigateUrl (pageNum);
+ h.CssClass = cssClass;
+ ctl = h;
+ }
} else {
if (!enabled) {
Label l = new Label ();
@@ -154,12 +158,14 @@ namespace System.Web.UI.WebControls
case ButtonType.Button:
Button btn = new Button ();
btn.CommandName = commandName;
+ btn.CommandArgument = pageNum.ToString ();
btn.Text = text;
break;
case ButtonType.Link:
LinkButton lbtn = new LinkButton ();
lbtn.CommandName = commandName;
+ lbtn.CommandArgument = pageNum.ToString ();
lbtn.Text = text;
ctl = lbtn;
break;
@@ -167,6 +173,7 @@ namespace System.Web.UI.WebControls
case ButtonType.Image:
ImageButton ibtn = new ImageButton ();
ibtn.CommandName = commandName;
+ ibtn.CommandArgument = pageNum.ToString ();
ibtn.ImageUrl = imageUrl;
ibtn.AlternateText = text;
ctl = ibtn;
@@ -251,20 +258,24 @@ namespace System.Web.UI.WebControls
public override void HandleEvent (CommandEventArgs e)
{
string commandName = e.CommandName;
+ int pageNum;
+
+ if (!Int32.TryParse (e.CommandArgument as string, out pageNum))
+ pageNum = 0;
+ else if (pageNum >= 1)
+ pageNum--;
+ else if (pageNum < 0)
+ pageNum = 0;
+
int newStartIndex = -1;
int pageSize = DataPager.PageSize;
-
- if (String.Compare (commandName, DataControlCommands.NextPageCommandArgument, StringComparison.OrdinalIgnoreCase) == 0) {
- newStartIndex = _startRowIndex + pageSize;
- if (newStartIndex > _totalRowCount)
- newStartIndex = _totalRowCount - pageSize;
- } else if (String.Compare (commandName, DataControlCommands.PreviousPageCommandArgument, StringComparison.OrdinalIgnoreCase) == 0) {
- newStartIndex = _startRowIndex - pageSize;
- if (newStartIndex < 0)
- newStartIndex = 0;
- } else {
+ int offset = pageSize * pageNum;
+
+ if (String.Compare (commandName, DataControlCommands.NextPageCommandArgument, StringComparison.OrdinalIgnoreCase) == 0 ||
+ String.Compare (commandName, DataControlCommands.PreviousPageCommandArgument, StringComparison.OrdinalIgnoreCase) == 0) {
+ newStartIndex = offset;
+ } else
newStartIndex = (Int32.Parse (commandName) - 1) * pageSize;
- }
if (newStartIndex != -1)
DataPager.SetPageProperties (newStartIndex, pageSize, true);