Author: lluis
Date: 2005-03-11 08:25:26 -0500 (Fri, 11 Mar 2005)
New Revision: 41698
Added:
trunk/mcs/class/System.Web/System.Web.UI.WebControls/ButtonFieldBase.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/CommandField.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlButton.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/GridView.js
Modified:
trunk/mcs/class/System.Web/System.Web.UI.WebControls/BulletedList.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/Button.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
trunk/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlField.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/GridView.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/Menu.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/PagerSettings.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs
trunk/mcs/class/System.Web/System.Web.UI.WebControls/TreeView.cs
Log:
2005-03-11 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* Button.cs, ImageButton.cs: Interpret PostBackOptions.ClientSubmit
correctly.
* CommandField.cs: Mostly implemented.
* Menu.cs: Use callback methods moved to ClientScriptManager.
* DataControlButton.cs: Internal control used to implement buttons
for navigating in data bound controls.
* DataControlField.cs, PagerSettings.cs: Use the new DataControlButton
to render the column headers.
* CheckBox.cs, RadioButton.cs, BulletedList.cs, TextBox.cs
DropDownList.cs, Calendar.cs, ListBox.cs, LinkButton.cs, TreeView.cs:
Don't use Page.GetPostBackClientEvent
since it is deprecated in 2.0.
* GridView.cs: Implemented some several interfaces.
Implemented support client sorting and page navigation (using
callbacks).
Implemented the autogenerated command column using the new
CommandField
class.
* ButtonFieldBase.cs: Implemented.
* GridView.js: New helper script to support client side sorting and
paging in the grid view.
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/BulletedList.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/BulletedList.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/BulletedList.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -135,7 +135,7 @@
case BulletedListDisplayMode.LinkButton:
//if (cacheIsEnabled && item.Enabled)
- writer.AddAttribute
(HtmlTextWriterAttribute.Href, Page.GetPostBackClientHyperlink (this,
(index.ToString (CultureInfo.InvariantCulture))));
+ writer.AddAttribute
(HtmlTextWriterAttribute.Href, Page.ClientScript.GetPostBackClientHyperlink
(this, (index.ToString (CultureInfo.InvariantCulture))));
//else
// writer.AddAttribute
(HtmlTextWriterAttribute.Disabled, "disabled");
writer.RenderBeginTag
(HtmlTextWriterTag.A);
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/Button.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/Button.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/Button.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -293,9 +293,9 @@
if (PostBackUrl != "")
ops.ActionUrl = PostBackUrl;
ops.PerformValidation = Page.Validators.Count > 0 &&
CausesValidation;
- if (ops.PerformValidation)
+ if (ops.PerformValidation && ValidationGroup != "")
ops.ValidationGroup = ValidationGroup;
- ops.ClientSubmit = UseSubmitBehavior;
+ ops.ClientSubmit = !UseSubmitBehavior;
ops.RequiresJavaScriptProtocol = false;
return ops;
}
@@ -317,17 +317,19 @@
if (script.Length > 0) script += ";";
PostBackOptions ops = GetPostBackOptions ();
- if (ops != null && ops.RequiresSpecialPostBack)
{
- script +=
Page.GetPostBackEventReference (ops);
+ bool submitBehavior = UseSubmitBehavior &&
!ops.ClientSubmit;
+
+ if (ops.RequiresSpecialPostBack) {
+ script +=
Page.ClientScript.GetPostBackEventReference (ops);
}
else if (CausesValidation &&
Page.Validators.Count > 0) {
- if (UseSubmitBehavior)
+ if (submitBehavior)
script +=
Utils.GetClientValidatedEvent (Page);
else
script +=
Utils.GetClientValidatedPostBack (this);
}
- else if (!UseSubmitBehavior) {
- script += Page.GetPostBackClientEvent
(this,"");
+ else if (!submitBehavior) {
+ script +=
Page.ClientScript.GetPostBackClientEvent (this,"");
}
#else
if (CausesValidation && Page.Validators.Count >
0) {
Added: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ButtonFieldBase.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ButtonFieldBase.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ButtonFieldBase.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -0,0 +1,87 @@
+//
+// System.Web.UI.WebControls.ButtonFieldBase.cs
+//
+// Authors:
+// Lluis Sanchez Gual ([EMAIL PROTECTED])
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+using System.Collections;
+using System.Collections.Specialized;
+using System.Web.UI;
+using System.ComponentModel;
+using System.Security.Permissions;
+
+namespace System.Web.UI.WebControls {
+
+ [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level =
AspNetHostingPermissionLevel.Minimal)]
+ [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand,
Level = AspNetHostingPermissionLevel.Minimal)]
+ public abstract class ButtonFieldBase : DataControlField
+ {
+ [WebCategoryAttribute ("Appearance")]
+ [DefaultValueAttribute (ButtonType.Link)]
+ public virtual ButtonType ButtonType {
+ get {
+ object ob = ViewState ["ButtonType"];
+ if (ob != null) return (ButtonType) ob;
+ return ButtonType.Link;
+ }
+ set {
+ ViewState ["ButtonType"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [DefaultValueAttribute (false)]
+ [WebCategoryAttribute ("Behavior")]
+ public virtual bool CausesValidation {
+ get {
+ object ob = ViewState ["CausesValidation"];
+ if (ob != null) return (bool) ob;
+ return false;
+ }
+ set {
+ ViewState ["CausesValidation"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [WebCategoryAttribute ("Behavior")]
+ [DefaultValueAttribute ("")]
+ public virtual string ValidationGroup {
+ get {
+ object ob = ViewState ["ValidationGroup"];
+ if (ob != null) return (string) ob;
+ return "";
+ }
+ set {
+ ViewState ["ValidationGroup"] = value;
+ OnFieldChanged ();
+ }
+ }
+ }
+}
+#endif
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -1375,7 +1375,7 @@
if (isLink) {
StringBuilder dispVal = new StringBuilder ();
dispVal.Append ("<a href=\"");
- dispVal.Append (Page.GetPostBackClientHyperlink
(this, eventArg));
+ dispVal.Append
(Page.ClientScript.GetPostBackClientHyperlink (this, eventArg));
dispVal.Append ("\" style=\"color: ");
if (foreground.IsEmpty) {
dispVal.Append (ColorTranslator.ToHtml
(defaultTextColor));
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2005-03-11 13:25:26 UTC (rev 41698)
@@ -1,3 +1,25 @@
+2005-03-11 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
+ * Button.cs, ImageButton.cs: Interpret PostBackOptions.ClientSubmit
+ correctly.
+ * CommandField.cs: Mostly implemented.
+ * Menu.cs: Use callback methods moved to ClientScriptManager.
+ * DataControlButton.cs: Internal control used to implement buttons
+ for navigating in data bound controls.
+ * DataControlField.cs, PagerSettings.cs: Use the new DataControlButton
+ to render the column headers.
+ * CheckBox.cs, RadioButton.cs, BulletedList.cs, TextBox.cs
+ DropDownList.cs, Calendar.cs, ListBox.cs, LinkButton.cs, TreeView.cs:
+ Don't use Page.GetPostBackClientEvent
+ since it is deprecated in 2.0.
+ * GridView.cs: Implemented some several interfaces.
+ Implemented support client sorting and page navigation (using
callbacks).
+ Implemented the autogenerated command column using the new
CommandField
+ class.
+ * ButtonFieldBase.cs: Implemented.
+ * GridView.js: New helper script to support client side sorting and
+ paging in the grid view.
+
2005-03-04 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* DataKey.cs: Implemented.
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -429,7 +429,7 @@
if (AutoPostBack){
writer.AddAttribute
(HtmlTextWriterAttribute.Onclick,
-
Page.GetPostBackClientEvent (this, String.Empty));
+
Page.ClientScript.GetPostBackClientEvent (this, String.Empty));
writer.AddAttribute ("language", "javascript");
}
Added: trunk/mcs/class/System.Web/System.Web.UI.WebControls/CommandField.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/CommandField.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/CommandField.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -0,0 +1,369 @@
+//
+// System.Web.UI.WebControls.CommandField.cs
+//
+// Authors:
+// Lluis Sanchez Gual ([EMAIL PROTECTED])
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+using System.Collections;
+using System.Collections.Specialized;
+using System.Web.UI;
+using System.ComponentModel;
+using System.Security.Permissions;
+
+namespace System.Web.UI.WebControls {
+
+ [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level =
AspNetHostingPermissionLevel.Minimal)]
+ [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand,
Level = AspNetHostingPermissionLevel.Minimal)]
+ public class CommandField : ButtonFieldBase
+ {
+ [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor,
System.Design, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor,
System.Drawing, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a")]
+ [WebCategoryAttribute ("Appearance")]
+ [UrlPropertyAttribute]
+ [DefaultValueAttribute ("")]
+ public virtual string CancelImageUrl {
+ get {
+ object ob = ViewState ["CancelImageUrl"];
+ if (ob != null) return (string) ob;
+ return "";
+ }
+ set {
+ ViewState ["CancelImageUrl"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [WebCategoryAttribute ("Appearance")]
+ [LocalizableAttribute (true)]
+ public virtual string CancelText {
+ get {
+ object ob = ViewState ["CancelText"];
+ if (ob != null) return (string) ob;
+ return "Cancel";
+ }
+ set {
+ ViewState ["CancelText"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor,
System.Design, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor,
System.Drawing, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a")]
+ [WebCategoryAttribute ("Appearance")]
+ [UrlPropertyAttribute]
+ [DefaultValueAttribute ("")]
+ public virtual string DeleteImageUrl {
+ get {
+ object ob = ViewState ["DeleteImageUrl"];
+ if (ob != null) return (string) ob;
+ return "";
+ }
+ set {
+ ViewState ["DeleteImageUrl"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [WebCategoryAttribute ("Appearance")]
+ [LocalizableAttribute (true)]
+ public virtual string DeleteText {
+ get {
+ object ob = ViewState ["DeleteText"];
+ if (ob != null) return (string) ob;
+ return "Delete";
+ }
+ set {
+ ViewState ["DeleteText"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor,
System.Design, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor,
System.Drawing, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a")]
+ [WebCategoryAttribute ("Appearance")]
+ [UrlPropertyAttribute]
+ [DefaultValueAttribute ("")]
+ public virtual string EditImageUrl {
+ get {
+ object ob = ViewState ["EditImageUrl"];
+ if (ob != null) return (string) ob;
+ return "";
+ }
+ set {
+ ViewState ["EditImageUrl"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [WebCategoryAttribute ("Appearance")]
+ [LocalizableAttribute (true)]
+ public virtual string EditText {
+ get {
+ object ob = ViewState ["EditText"];
+ if (ob != null) return (string) ob;
+ return "Edit";
+ }
+ set {
+ ViewState ["EditText"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor,
System.Design, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor,
System.Drawing, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a")]
+ [WebCategoryAttribute ("Appearance")]
+ [UrlPropertyAttribute]
+ [DefaultValueAttribute ("")]
+ public virtual string InsertImageUrl {
+ get {
+ object ob = ViewState ["InsertImageUrl"];
+ if (ob != null) return (string) ob;
+ return "";
+ }
+ set {
+ ViewState ["InsertImageUrl"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [WebCategoryAttribute ("Appearance")]
+ [LocalizableAttribute (true)]
+ public virtual string InsertText {
+ get {
+ object ob = ViewState ["InsertText"];
+ if (ob != null) return (string) ob;
+ return "Insert";
+ }
+ set {
+ ViewState ["InsertText"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor,
System.Design, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor,
System.Drawing, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a")]
+ [WebCategoryAttribute ("Appearance")]
+ [UrlPropertyAttribute]
+ [DefaultValueAttribute ("")]
+ public virtual string NewImageUrl {
+ get {
+ object ob = ViewState ["NewImageUrl"];
+ if (ob != null) return (string) ob;
+ return "";
+ }
+ set {
+ ViewState ["NewImageUrl"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [WebCategoryAttribute ("Appearance")]
+ [LocalizableAttribute (true)]
+ public virtual string NewText {
+ get {
+ object ob = ViewState ["NewText"];
+ if (ob != null) return (string) ob;
+ return "New";
+ }
+ set {
+ ViewState ["NewText"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor,
System.Design, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor,
System.Drawing, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a")]
+ [WebCategoryAttribute ("Appearance")]
+ [UrlPropertyAttribute]
+ [DefaultValueAttribute ("")]
+ public virtual string SelectImageUrl {
+ get {
+ object ob = ViewState ["SelectImageUrl"];
+ if (ob != null) return (string) ob;
+ return "";
+ }
+ set {
+ ViewState ["SelectImageUrl"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [WebCategoryAttribute ("Appearance")]
+ [LocalizableAttribute (true)]
+ public virtual string SelectText {
+ get {
+ object ob = ViewState ["SelectText"];
+ if (ob != null) return (string) ob;
+ return "Select";
+ }
+ set {
+ ViewState ["SelectText"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [DefaultValueAttribute (true)]
+ [WebCategoryAttribute ("Behavior")]
+ public virtual bool ShowCancelButton {
+ get {
+ object ob = ViewState ["ShowCancelButton"];
+ if (ob != null) return (bool) ob;
+ return true;
+ }
+ set {
+ ViewState ["ShowCancelButton"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [DefaultValueAttribute (false)]
+ [WebCategoryAttribute ("Behavior")]
+ public virtual bool ShowDeleteButton {
+ get {
+ object ob = ViewState ["ShowDeleteButton"];
+ if (ob != null) return (bool) ob;
+ return false;
+ }
+ set {
+ ViewState ["ShowDeleteButton"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [DefaultValueAttribute (false)]
+ [WebCategoryAttribute ("Behavior")]
+ public virtual bool ShowEditButton {
+ get {
+ object ob = ViewState ["ShowEditButton"];
+ if (ob != null) return (bool) ob;
+ return false;
+ }
+ set {
+ ViewState ["ShowEditButton"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [DefaultValueAttribute (false)]
+ [WebCategoryAttribute ("Behavior")]
+ public virtual bool ShowSelectButton {
+ get {
+ object ob = ViewState ["ShowSelectButton"];
+ if (ob != null) return (bool) ob;
+ return false;
+ }
+ set {
+ ViewState ["ShowSelectButton"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [DefaultValueAttribute (false)]
+ [WebCategoryAttribute ("Behavior")]
+ public virtual bool ShowInsertButton {
+ get {
+ object ob = ViewState ["ShowInsertButton"];
+ if (ob != null) return (bool) ob;
+ return false;
+ }
+ set {
+ ViewState ["ShowInsertButton"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor,
System.Design, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor,
System.Drawing, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a")]
+ [WebCategoryAttribute ("Appearance")]
+ [UrlPropertyAttribute]
+ [DefaultValueAttribute ("")]
+ public virtual string UpdateImageUrl {
+ get {
+ object ob = ViewState ["UpdateImageUrl"];
+ if (ob != null) return (string) ob;
+ return "";
+ }
+ set {
+ ViewState ["UpdateImageUrl"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ [WebCategoryAttribute ("Appearance")]
+ [LocalizableAttribute (true)]
+ public virtual string UpdateText {
+ get {
+ object ob = ViewState ["UpdateText"];
+ if (ob != null) return (string) ob;
+ return "Update";
+ }
+ set {
+ ViewState ["UpdateText"] = value;
+ OnFieldChanged ();
+ }
+ }
+
+ public override void InitializeCell (DataControlFieldCell cell,
+ DataControlCellType cellType, DataControlRowState
rowState, int rowIndex)
+ {
+ string index = rowIndex.ToString ();
+
+ if (cellType == DataControlCellType.DataCell)
+ {
+ if ((rowState & DataControlRowState.Edit) != 0)
{
+ cell.Controls.Add (new
DataControlButton (Control, UpdateText, UpdateImageUrl, "Update", index,
false));
+ if (ShowCancelButton) {
+ AddSeparator (cell);
+ cell.Controls.Add (new
DataControlButton (Control, CancelText, CancelImageUrl, "Cancel", index,
false));
+ }
+ } else {
+ if (ShowEditButton) {
+ AddSeparator (cell);
+ cell.Controls.Add (new
DataControlButton (Control, EditText, EditImageUrl, "Edit", index, false));
+ }
+ if (ShowDeleteButton) {
+ AddSeparator (cell);
+ cell.Controls.Add (new
DataControlButton (Control, DeleteText, DeleteImageUrl, "Delete", index,
false));
+ }
+ if (ShowSelectButton) {
+ AddSeparator (cell);
+ cell.Controls.Add (new
DataControlButton (Control, SelectText, SelectImageUrl, "Select", index,
false));
+ }
+ if (ShowInsertButton) {
+ AddSeparator (cell);
+ cell.Controls.Add (new
DataControlButton (Control, InsertText, InsertImageUrl, "Insert", index,
false));
+ }
+ }
+ } else
+ base.InitializeCell (cell, cellType, rowState,
rowIndex);
+ }
+
+ void AddSeparator (DataControlFieldCell cell)
+ {
+ if (cell.Controls.Count > 0) {
+ Literal lit = new Literal ();
+ lit.Text = " ";
+ cell.Controls.Add (lit);
+ }
+ }
+ }
+}
+#endif
Added: trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlButton.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlButton.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlButton.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -0,0 +1,142 @@
+//
+// System.Web.UI.WebControls.DataControlButton.cs
+//
+// Authors:
+// Lluis Sanchez Gual ([EMAIL PROTECTED])
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+
+namespace System.Web.UI.WebControls
+{
+ internal class DataControlButton: Button
+ {
+ Control container;
+
+ public DataControlButton (Control container)
+ {
+ }
+
+ public DataControlButton (Control container, string text,
string image, string command, string commandArg, bool allowCallback)
+ {
+ this.container = container;
+ Text = text;
+ ImageUrl = image;
+ CommandName = command;
+ CommandArgument = commandArg;
+ AllowCallback = allowCallback;
+ }
+
+ public string ImageUrl {
+ get {
+ object o = ViewState["iu"];
+ if (o != null) return (string) o;
+ return String.Empty;
+ }
+ set {
+ ViewState["iu"] = value;
+ }
+ }
+
+ public bool AllowCallback {
+ get {
+ object o = ViewState["ac"];
+ if (o != null) return (bool) o;
+ return true;
+ }
+ set {
+ ViewState["ac"] = value;
+ }
+ }
+
+ protected override void Render (HtmlTextWriter writer)
+ {
+ if (CommandName.Length > 0)
+ {
+ string postScript = null;
+ string callScript = null;
+
+ IPostBackContainer pcner = container as
IPostBackContainer;
+ if (pcner != null) {
+ PostBackOptions ops =
pcner.GetPostBackOptions (this);
+ postScript =
container.Page.ClientScript.GetPostBackEventReference (ops);
+ } else
+ postScript =
Page.ClientScript.GetPostBackClientEvent (this, "");
+
+ if (CausesValidation && Page.Validators.Count >
0) {
+ postScript =
Utils.GetClientValidatedEvent (Page) + postScript;
+ }
+
+ if (AllowCallback) {
+ ICallbackContainer ccner = container as
ICallbackContainer;
+ if (ccner != null)
+ callScript =
ccner.GetCallbackScript (this, CommandName + "$" + CommandArgument);
+ }
+
+ if (ImageUrl.Length > 0) {
+ writer.AddAttribute
(HtmlTextWriterAttribute.Type, "image");
+ writer.AddAttribute
(HtmlTextWriterAttribute.Src, ResolveUrl (ImageUrl));
+ if (callScript != null)
+ writer.AddAttribute
(HtmlTextWriterAttribute.Onclick, callScript);
+ else
+ writer.AddAttribute
(HtmlTextWriterAttribute.Onclick, postScript);
+ if (Text.Length > 0)
+ writer.AddAttribute
(HtmlTextWriterAttribute.Alt, Text);
+ writer.RenderBeginTag
(HtmlTextWriterTag.Input);
+ writer.RenderEndTag ();
+ }
+ else {
+ if (callScript != null) {
+ writer.AddAttribute
(HtmlTextWriterAttribute.Onclick, callScript);
+ writer.AddAttribute
(HtmlTextWriterAttribute.Href, "javascript:");
+ }
+ else
+ writer.AddAttribute
(HtmlTextWriterAttribute.Href, postScript);
+ writer.RenderBeginTag
(HtmlTextWriterTag.A);
+ writer.Write (Text);
+ writer.RenderEndTag ();
+ }
+ } else {
+ if (ImageUrl.Length > 0) {
+ writer.AddAttribute
(HtmlTextWriterAttribute.Src, ResolveUrl (ImageUrl));
+ if (Text.Length > 0)
+ writer.AddAttribute
(HtmlTextWriterAttribute.Alt, Text);
+ writer.RenderBeginTag
(HtmlTextWriterTag.Img);
+ writer.RenderEndTag ();
+ }
+ else {
+ writer.Write (Text);
+ }
+ }
+ }
+ }
+}
+
+#endif
Modified:
trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlField.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlField.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataControlField.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -3,6 +3,7 @@
//
// Authors:
// Sanjay Gupta ([EMAIL PROTECTED])
+// Lluis Sanchez Gual ([EMAIL PROTECTED])
//
// (C) 2004 Novell, Inc. (http://www.novell.com)
//
@@ -81,56 +82,14 @@
public virtual void InitializeCell (DataControlFieldCell cell,
DataControlCellType cellType, DataControlRowState
rowState, int rowIndex)
{
- bool isDataControl = control is DataBoundControl;
-
if (cellType == DataControlCellType.Header &&
ShowHeader)
{
- if (HeaderImageUrl != "")
- {
- if (sortingEnabled && SortExpression !=
"") {
- if (isDataControl) {
- HyperLink link = new
HyperLink ();
- link.ImageUrl =
HeaderImageUrl;
- link.NavigateUrl =
control.Page.GetPostBackClientHyperlink (control, "sort$" + SortExpression);
- if (HeaderText != "")
- link.Text =
HeaderText;
- cell.Controls.Add
(link);
- } else {
- ImageButton img = new
ImageButton ();
- img.CommandName =
"Sort";
- img.CommandArgument =
SortExpression;
- img.ImageUrl =
HeaderImageUrl;
- if (HeaderText != "")
-
img.AlternateText = HeaderText;
- cell.Controls.Add (img);
- }
- }
- else {
- Image img = new Image ();
- img.ImageUrl = HeaderImageUrl;
- if (HeaderText != "")
- img.AlternateText =
HeaderText;
- cell.Controls.Add (img);
- }
+ if (HeaderText != "" || HeaderImageUrl != "") {
+ if (sortingEnabled)
+ cell.Controls.Add (new
DataControlButton (control, HeaderText, HeaderImageUrl, "Sort", SortExpression,
true));
+ else
+ cell.Controls.Add (new
DataControlButton (control, HeaderText, HeaderImageUrl, "", "", true));
}
- else if (sortingEnabled && SortExpression != "")
- {
- if (isDataControl) {
- HyperLink link = new HyperLink
();
- link.Text = HeaderText;
- link.NavigateUrl =
control.Page.GetPostBackClientHyperlink (control, "sort$" + SortExpression);
- cell.Controls.Add (link);
- } else {
- LinkButton btn = new LinkButton
();
- btn.Text = HeaderText;
- btn.CommandName = "Sort";
- btn.CommandArgument =
SortExpression;
- cell.Controls.Add (btn);
- }
- }
- else {
- cell.Text = HeaderText;
- }
}
else if (cellType == DataControlCellType.Footer) {
cell.Text = FooterText;
@@ -191,10 +150,9 @@
tracking = true;
}
- [MonoTODO]
public virtual void ValidateSupportsCallback ()
{
- throw new NotImplementedException ();
+ throw new NotSupportedException ("Callback not
supported");
}
void IStateManager.LoadViewState(object savedState)
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -186,7 +186,7 @@
if(AutoPostBack && Page != null)
{
-
writer.AddAttribute(HtmlTextWriterAttribute.Onchange,
Page.GetPostBackClientEvent(this,""));
+
writer.AddAttribute(HtmlTextWriterAttribute.Onchange,
Page.ClientScript.GetPostBackClientEvent(this,""));
writer.AddAttribute("language", "javascript");
}
}
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/GridView.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/GridView.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/GridView.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -34,6 +34,8 @@
using System.ComponentModel;
using System.Web.UI;
using System.Security.Permissions;
+using System.Text;
+using System.IO;
namespace System.Web.UI.WebControls
{
@@ -42,7 +44,7 @@
[DefaultEventAttribute ("SelectedIndexChanged")]
[AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level =
AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand,
Level = AspNetHostingPermissionLevel.Minimal)]
- public class GridView: CompositeDataBoundControl, IPostBackEventHandler
+ public class GridView: CompositeDataBoundControl,
IPostBackEventHandler, ICallbackEventHandler, ICallbackContainer,
IPostBackContainer
{
Table table;
GridViewRowCollection rows;
@@ -54,6 +56,10 @@
IOrderedDictionary currentEditRowKeys;
IOrderedDictionary currentEditNewValues;
IOrderedDictionary currentEditOldValues;
+
+ CommandField commandField;
+
+ ITemplate pagerTemplate;
// View state
DataControlFieldCollection columns;
@@ -538,6 +544,20 @@
}
}
+ [WebCategoryAttribute ("Behavior")]
+ [DefaultValueAttribute (false)]
+ public virtual bool EnableSortingAndPagingCallbacks {
+ get {
+ object ob = ViewState
["EnableSortingAndPagingCallbacks"];
+ if (ob != null) return (bool) ob;
+ return false;
+ }
+ set {
+ ViewState ["EnableSortingAndPagingCallbacks"] =
value;
+ RequireBinding ();
+ }
+ }
+
[DesignerSerializationVisibilityAttribute
(DesignerSerializationVisibility.Hidden)]
[BrowsableAttribute (false)]
public virtual GridViewRow FooterRow {
@@ -640,7 +660,20 @@
}
}
+ [DefaultValueAttribute (10)]
[WebCategoryAttribute ("Paging")]
+ public int PageSize {
+ get {
+ object ob = ViewState ["PageSize"];
+ if (ob != null) return (int) ob;
+ return 10;
+ }
+ set {
+ ViewState ["PageSize"] = value;
+ }
+ }
+
+ [WebCategoryAttribute ("Paging")]
[DesignerSerializationVisibilityAttribute
(DesignerSerializationVisibility.Content)]
[NotifyParentPropertyAttribute (true)]
[PersistenceModeAttribute (PersistenceMode.InnerProperty)]
@@ -669,19 +702,17 @@
return pagerStyle;
}
}
- [DefaultValueAttribute (10)]
- [WebCategoryAttribute ("Paging")]
- public int PageSize {
- get {
- object ob = ViewState ["PageSize"];
- if (ob != null) return (int) ob;
- return 10;
- }
- set {
- ViewState ["PageSize"] = value;
- }
+
+
+ [DefaultValue (null)]
+ [TemplateContainer (typeof(GridView), BindingDirection.OneWay)]
+ [PersistenceMode (PersistenceMode.InnerProperty)]
+ [Browsable (false)]
+ public ITemplate PagerTemplate {
+ get { return pagerTemplate; }
+ set { pagerTemplate = value; RequireBinding (); }
}
-
+
[DesignerSerializationVisibilityAttribute
(DesignerSerializationVisibility.Hidden)]
[BrowsableAttribute (false)]
public virtual GridViewRowCollection Rows {
@@ -861,9 +892,22 @@
ArrayList list = new ArrayList ();
ArrayList keyList = new ArrayList ();
+
+ DataControlField[] fields;
+
+ if (AutoGenerateEditButton || AutoGenerateDeleteButton
|| AutoGenerateSelectButton) {
+ commandField = new CommandField ();
+ commandField.ShowEditButton =
AutoGenerateEditButton;
+ commandField.ShowDeleteButton =
AutoGenerateDeleteButton;
+ commandField.ShowSelectButton =
AutoGenerateSelectButton;
+ fields = new DataControlField [Columns.Count +
1];
+ fields [0] = commandField;
+ Columns.CopyTo (fields, 1);
+ } else {
+ fields = new DataControlField [Columns.Count];
+ Columns.CopyTo (fields, 0);
+ }
- DataControlField[] fields = new DataControlField
[Columns.Count];
- Columns.CopyTo (fields, 0);
foreach (DataControlField field in fields)
field.Initialize (AllowSorting, this);
@@ -909,8 +953,12 @@
}
if (showPager && PagerSettings.Position ==
PagerPosition.Bottom || PagerSettings.Position == PagerPosition.TopAndBottom) {
- bottomPagerRow = CreatePagerRow ();
- table.Rows.Add (bottomPagerRow);
+ if (pagerTemplate != null)
+ pagerTemplate.InstantiateIn (this);
+ else {
+ bottomPagerRow = CreatePagerRow ();
+ table.Rows.Add (bottomPagerRow);
+ }
}
rows = new GridViewRowCollection (list);
@@ -946,62 +994,6 @@
case DataControlRowType.Footer: ctype =
DataControlCellType.Footer; break;
default: ctype = DataControlCellType.DataCell;
break;
}
-
- if (AutoGenerateEditButton || AutoGenerateDeleteButton
|| AutoGenerateSelectButton) {
- TableCell cell = new TableCell ();
- row.Cells.Add (cell);
-
- if (ctype == DataControlCellType.DataCell)
- {
- if ((row.RowState &
DataControlRowState.Edit) != 0)
- {
- HyperLink link = new HyperLink
();
- link.Text = "Update";
- link.NavigateUrl =
Page.GetPostBackClientHyperlink (this, "update");
- cell.Controls.Add (link);
-
- Literal lit = new Literal ();
- lit.Text = " ";
- cell.Controls.Add (lit);
-
- link = new HyperLink ();
- link.Text = "Cancel";
- link.NavigateUrl =
Page.GetPostBackClientHyperlink (this, "cancel");
- cell.Controls.Add (link);
- }
- else
- {
- if (AutoGenerateEditButton) {
- HyperLink link = new
HyperLink ();
- link.Text = "Edit";
- link.NavigateUrl =
Page.GetPostBackClientHyperlink (this, "edit$" + row.RowIndex);
- cell.Controls.Add
(link);
- }
- if (AutoGenerateDeleteButton) {
- HyperLink link = new
HyperLink ();
- link.Text = "Delete";
- link.NavigateUrl =
Page.GetPostBackClientHyperlink (this, "delete$" + row.RowIndex);
- if (cell.Controls.Count
> 0) {
- Literal lit =
new Literal ();
- lit.Text =
" ";
-
cell.Controls.Add (lit);
- }
- cell.Controls.Add
(link);
- }
- if (AutoGenerateSelectButton) {
- HyperLink link = new
HyperLink ();
- link.Text = "Select";
- link.NavigateUrl =
Page.GetPostBackClientHyperlink (this, "select$" + row.RowIndex);
- if (cell.Controls.Count
> 0) {
- Literal lit =
new Literal ();
- lit.Text =
" ";
-
cell.Controls.Add (lit);
- }
- cell.Controls.Add
(link);
- }
- }
- }
- }
for (int n=0; n<fields.Length; n++) {
DataControlField field = fields [n];
@@ -1038,6 +1030,15 @@
return dic;
}
+ protected override HtmlTextWriterTag TagKey {
+ get {
+ if (EnableSortingAndPagingCallbacks)
+ return HtmlTextWriterTag.Div;
+ else
+ return HtmlTextWriterTag.Table;
+ }
+ }
+
public sealed override void DataBind ()
{
if (AllowPaging) {
@@ -1093,33 +1094,30 @@
protected virtual void RaisePostBackEvent (string eventArgument)
{
- string eventName;
- string param;
-
int i = eventArgument.IndexOf ('$');
- if (i != -1) {
- eventName = eventArgument.Substring (0, i);
- param = eventArgument.Substring (i + 1);
- } else {
- eventName = eventArgument;
- param = null;
- }
-
+ if (i != -1)
+ ProcessEvent (eventArgument.Substring (0, i),
eventArgument.Substring (i + 1));
+ else
+ ProcessEvent (eventArgument, null);
+ }
+
+ void ProcessEvent (string eventName, string param)
+ {
switch (eventName)
{
- case "page":
+ case "Page":
int newIndex = -1;
switch (param) {
- case "first":
+ case "First":
newIndex = 0;
break;
- case "last":
+ case "Last":
newIndex = PageCount -
1;
break;
- case "next":
+ case "Next":
if (PageIndex <
PageCount - 1) newIndex = PageIndex + 1;
break;
- case "prev":
+ case "Prev":
if (PageIndex > 0)
newIndex = PageIndex - 1;
break;
default:
@@ -1129,27 +1127,27 @@
ShowPage (newIndex);
break;
- case "select":
+ case "Select":
SelectRow (int.Parse (param));
break;
- case "edit":
+ case "Edit":
EditRow (int.Parse (param));
break;
- case "update":
+ case "Update":
UpdateRow ();
break;
- case "cancel":
+ case "Cancel":
CancelEdit ();
break;
- case "delete":
+ case "Delete":
DeleteRow (int.Parse (param));
break;
- case "sort":
+ case "Sort":
Sort (param);
break;
}
@@ -1166,6 +1164,20 @@
} else
newDirection = sortDirection;
+ Sort (newSortExpression, newDirection);
+ }
+
+ public void Sort (string newSortExpression, SortDirection
newSortDirection)
+ {
+ SortDirection newDirection;
+ if (sortExpression == newSortExpression) {
+ if (sortDirection == SortDirection.Ascending)
+ newDirection = SortDirection.Descending;
+ else
+ newDirection = SortDirection.Ascending;
+ } else
+ newDirection = sortDirection;
+
GridViewSortEventArgs args = new GridViewSortEventArgs
(newSortExpression, newDirection);
OnSorting (args);
if (args.Cancel) return;
@@ -1250,7 +1262,7 @@
return dargs.ExceptionHandled;
}
- void DeleteRow (int rowIndex)
+ public void DeleteRow (int rowIndex)
{
GridViewRow row = Rows [rowIndex];
currentEditRowKeys = DataKeys [rowIndex].Values;
@@ -1372,8 +1384,75 @@
if (states[12] != null && oldEditValues != null)
((IStateManager)oldEditValues).LoadViewState (states[12]);
}
+ string ICallbackEventHandler.RaiseCallbackEvent (string
eventArgs)
+ {
+ string[] clientData = eventArgs.Split ('|');
+ pageIndex = int.Parse (clientData[0]);
+ sortExpression = HttpUtility.UrlDecode (clientData[1]);
+ if (sortExpression == "") sortExpression = null;
+ RequireBinding ();
+
+ RaisePostBackEvent (clientData[2]);
+ EnsureDataBound ();
+
+ StringWriter sw = new StringWriter ();
+ sw.Write (PageIndex.ToString() + '|' + SortExpression +
'|');
+
+ HtmlTextWriter writer = new HtmlTextWriter (sw);
+ RenderGrid (writer);
+ return sw.ToString ();
+ }
+
+ string ICallbackContainer.GetCallbackScript (IButtonControl
control, string argument)
+ {
+ if (EnableSortingAndPagingCallbacks)
+ return "javascript:GridView_ClientEvent (\"" +
ClientID + "\",\"" + control.CommandName + "$" + control.CommandArgument +
"\"); return false;";
+ else
+ return null;
+ }
+
+ PostBackOptions IPostBackContainer.GetPostBackOptions
(IButtonControl control)
+ {
+ return new PostBackOptions (this, control.CommandName +
"$" + control.CommandArgument, null, false, true, false, true, false, null);
+ }
+
+ protected override void OnPreRender (EventArgs e)
+ {
+ base.OnPreRender (e);
+
+ if (EnableSortingAndPagingCallbacks)
+ {
+ if
(!Page.ClientScript.IsClientScriptIncludeRegistered (typeof(GridView),
"GridView.js")) {
+ string url =
Page.ClientScript.GetWebResourceUrl (typeof(GridView), "GridView.js");
+
Page.ClientScript.RegisterClientScriptInclude (typeof(GridView), "GridView.js",
url);
+ }
+
+ string cgrid = ClientID + "_data";
+ string script = string.Format ("var {0} = new
Object ();\n", cgrid);
+ script += string.Format ("{0}.pageIndex =
{1};\n", cgrid, ClientScriptManager.GetScriptLiteral (PageIndex));
+ script += string.Format ("{0}.sortExp =
{1};\n", cgrid, ClientScriptManager.GetScriptLiteral (SortExpression == null ?
"" : SortExpression));
+ script += string.Format ("{0}.uid = {1};\n",
cgrid, ClientScriptManager.GetScriptLiteral (UniqueID));
+ Page.ClientScript.RegisterStartupScript
(typeof(TreeView), this.UniqueID, script, true);
+
+ // Make sure the basic script infrastructure is
rendered
+ Page.ClientScript.GetCallbackEventReference (this,
"null", "", "null");
+ Page.ClientScript.GetPostBackClientHyperlink
(this, "");
+ }
+ }
+
protected override void Render (HtmlTextWriter writer)
{
+ if (EnableSortingAndPagingCallbacks)
+ base.RenderBeginTag (writer);
+
+ RenderGrid (writer);
+
+ if (EnableSortingAndPagingCallbacks)
+ base.RenderEndTag (writer);
+ }
+
+ void RenderGrid (HtmlTextWriter writer)
+ {
switch (GridLines) {
case GridLines.Horizontal:
writer.AddAttribute
(HtmlTextWriterAttribute.Rules, "rows");
Added: trunk/mcs/class/System.Web/System.Web.UI.WebControls/GridView.js
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/GridView.js
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/GridView.js
2005-03-11 13:25:26 UTC (rev 41698)
@@ -0,0 +1,21 @@
+function GridView_ClientEvent (ctrlId, evnt)
+{
+ var gridData = eval (ctrlId + "_data");
+ var clientData = gridData.pageIndex + '|' + escape (gridData.sortExp) +
'|' + evnt;
+ WebForm_DoCallback (gridData.uid, clientData, GridView_ClientRender,
ctrlId, GridView_ClientRender_Error);
+}
+
+function GridView_ClientRender (data, ctx)
+{
+ var gridData = eval (ctx + "_data");
+ var grid = document.getElementById (ctx);
+ var i = data.indexOf ("|");
+ var j = data.indexOf ("|", i+1);
+ gridData.pageIndex = parseInt (data.substring (0, i));
+ gridData.sortExp = unescape (data.substring (i+1, j));
+ grid.innerHTML = data.substr (j+1);
+}
+
+function GridView_ClientRender_Error (data, ctx)
+{
+}
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -241,7 +241,7 @@
if (PostBackUrl != "")
ops.ActionUrl = PostBackUrl;
ops.PerformValidation = Page.Validators.Count > 0 &&
CausesValidation;
- if (ops.PerformValidation)
+ if (ops.PerformValidation && ValidationGroup != "")
ops.ValidationGroup = ValidationGroup;
ops.RequiresJavaScriptProtocol = false;
return ops;
@@ -261,8 +261,8 @@
if (script.Length > 0) script += ";";
PostBackOptions ops = GetPostBackOptions ();
- if (ops != null && ops.RequiresSpecialPostBack)
{
- script +=
Page.GetPostBackEventReference (ops);
+ if (ops.RequiresSpecialPostBack ||
ops.ClientSubmit) {
+ script +=
Page.ClientScript.GetPostBackEventReference (ops);
}
else if (CausesValidation &&
Page.Validators.Count > 0) {
script += Utils.GetClientValidatedEvent
(Page);
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -184,7 +184,7 @@
if (PostBackUrl != "")
ops.ActionUrl = PostBackUrl;
ops.PerformValidation = Page.Validators.Count > 0 &&
CausesValidation;
- if (ops.PerformValidation)
+ if (ops.PerformValidation && ValidationGroup != "")
ops.ValidationGroup = ValidationGroup;
ops.RequiresJavaScriptProtocol = false;
return ops;
@@ -260,20 +260,21 @@
base.AddAttributesToRender (writer);
#if NET_2_0
if (Page != null && Enabled) {
+
+ if (OnClientClick != "")
+ writer.AddAttribute
(HtmlTextWriterAttribute.Onclick, OnClientClick);
+
string script = "";
-
- script = OnClientClick;
- if (script.Length > 0) script += ";";
-
+
PostBackOptions ops = GetPostBackOptions ();
- if (ops != null && ops.RequiresSpecialPostBack)
{
- script +=
Page.GetPostBackEventReference (ops);
+ if (ops.RequiresSpecialPostBack ||
ops.ClientSubmit) {
+ script =
Page.ClientScript.GetPostBackEventReference (ops);
}
else if (CausesValidation &&
Page.Validators.Count > 0) {
- script +=
Utils.GetClientValidatedPostBack (this);
+ script =
Utils.GetClientValidatedPostBack (this);
}
else {
- script += Page.GetPostBackClientEvent
(this,"");
+ script =
Page.ClientScript.GetPostBackClientEvent (this,"");
}
if (script != "")
writer.AddAttribute
(HtmlTextWriterAttribute.Href, "javascript:" + script);
@@ -288,7 +289,7 @@
return;
}
writer.AddAttribute
(HtmlTextWriterAttribute.Href,
-
Page.GetPostBackClientHyperlink (this, ""));
+
Page.ClientScript.GetPostBackClientHyperlink (this, ""));
}
#endif
}
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -131,7 +131,7 @@
if (AutoPostBack && Page != null){
writer.AddAttribute
(HtmlTextWriterAttribute.Onchange,
-
Page.GetPostBackClientEvent (this, ""));
+
Page.ClientScript.GetPostBackClientEvent (this, ""));
writer.AddAttribute ("language", "javascript");
}
}
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/Menu.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/Menu.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/Menu.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -806,7 +806,7 @@
base.OnPreRender (e);
if (!Page.ClientScript.IsClientScriptIncludeRegistered
(typeof(Menu), "Menu.js")) {
- string url = Page.GetWebResourceUrl
(typeof(Menu), "Menu.js");
+ string url =
Page.ClientScript.GetWebResourceUrl (typeof(Menu), "Menu.js");
Page.ClientScript.RegisterClientScriptInclude
(typeof(Menu), "Menu.js", url);
}
@@ -929,7 +929,7 @@
writer.AddAttribute ("onmouseout", string.Format
("javascript:Menu_OutScrollBtn ('{0}','{1}','{2}')", ClientID, item.Path, "u"));
writer.RenderBeginTag (HtmlTextWriterTag.Div);
- string src = ScrollUpImageUrl != "" ? ScrollUpImageUrl
: Page.GetWebResourceUrl (typeof(Menu), "arrow_up.gif");
+ string src = ScrollUpImageUrl != "" ? ScrollUpImageUrl
: Page.ClientScript.GetWebResourceUrl (typeof(Menu), "arrow_up.gif");
writer.AddAttribute ("src", src);
writer.AddAttribute ("alt", ScrollUpText);
writer.RenderBeginTag (HtmlTextWriterTag.Img);
@@ -955,7 +955,7 @@
writer.AddAttribute ("onmouseout", string.Format
("javascript:Menu_OutScrollBtn ('{0}','{1}','{2}')", ClientID, item.Path, "d"));
writer.RenderBeginTag (HtmlTextWriterTag.Div);
- src = ScrollDownImageUrl != "" ? ScrollDownImageUrl :
Page.GetWebResourceUrl (typeof(Menu), "arrow_down.gif");
+ src = ScrollDownImageUrl != "" ? ScrollDownImageUrl :
Page.ClientScript.GetWebResourceUrl (typeof(Menu), "arrow_down.gif");
writer.AddAttribute ("src", src);
writer.AddAttribute ("alt", ScrollDownText);
writer.RenderBeginTag (HtmlTextWriterTag.Img);
@@ -1276,7 +1276,7 @@
string GetClientEvent (MenuItem item)
{
- return Page.GetPostBackClientHyperlink (this,
item.Path);
+ return Page.ClientScript.GetPostBackClientHyperlink
(this, item.Path);
}
}
}
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/PagerSettings.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/PagerSettings.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/PagerSettings.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -262,13 +262,13 @@
{
if (currentPage > 0) {
if (Mode ==
PagerButtons.NextPreviousFirstLast)
- row.Cells.Add (CreateCell
(FirstPageText, FirstPageImageUrl, "page$first"));
- row.Cells.Add (CreateCell
(PreviousPageText, PreviousPageImageUrl, "page$prev"));
+ row.Cells.Add (CreateCell
(FirstPageText, FirstPageImageUrl, "Page", "First"));
+ row.Cells.Add (CreateCell
(PreviousPageText, PreviousPageImageUrl, "Page", "Prev"));
}
if (currentPage < pageCount - 1) {
- row.Cells.Add (CreateCell
(NextPageText, NextPageImageUrl, "page$next"));
+ row.Cells.Add (CreateCell
(NextPageText, NextPageImageUrl, "Page", "Next"));
if (Mode ==
PagerButtons.NextPreviousFirstLast)
- row.Cells.Add (CreateCell
(LastPageText, LastPageImageUrl, "page$last"));
+ row.Cells.Add (CreateCell
(LastPageText, LastPageImageUrl, "Page", "Last"));
}
}
else if (Mode == PagerButtons.Numeric || Mode ==
PagerButtons.NumericFirstLast)
@@ -279,35 +279,26 @@
if (first > 0) {
if (Mode ==
PagerButtons.NumericFirstLast)
- row.Cells.Add (CreateCell
(FirstPageText, FirstPageImageUrl, "page$first"));
- row.Cells.Add (CreateCell
(PreviousPageText, PreviousPageImageUrl, "page$prev"));
+ row.Cells.Add (CreateCell
(FirstPageText, FirstPageImageUrl, "Page", "First"));
+ row.Cells.Add (CreateCell
(PreviousPageText, PreviousPageImageUrl, "Page", "Prev"));
}
for (int n = first; n < last; n++)
- row.Cells.Add (CreateCell
(n.ToString(), string.Empty, (n != currentPage) ? "page$" + n : null));
+ row.Cells.Add (CreateCell
(n.ToString(), string.Empty, (n != currentPage) ? "Page" + n : "",
n.ToString()));
if (last < pageCount - 1) {
- row.Cells.Add (CreateCell
(NextPageText, NextPageImageUrl, "page$next"));
+ row.Cells.Add (CreateCell
(NextPageText, NextPageImageUrl, "Page", "Next"));
if (Mode ==
PagerButtons.NumericFirstLast)
- row.Cells.Add (CreateCell
(LastPageText, LastPageImageUrl, "page$last"));
+ row.Cells.Add (CreateCell
(LastPageText, LastPageImageUrl, "Page", "Last"));
}
}
return table;
}
- TableCell CreateCell (string text, string image, string
theEvent)
+ TableCell CreateCell (string text, string image, string
command, string argument)
{
TableCell cell = new TableCell ();
- if (theEvent != null) {
- HyperLink link = new HyperLink ();
- link.ImageUrl = image;
- link.Text = text;
- link.NavigateUrl =
ctrl.Page.GetPostBackClientHyperlink (ctrl, theEvent);
- cell.Controls.Add (link);
- } else {
- // Only numbers don't have an event
- cell.Text = text;
- }
+ cell.Controls.Add (new DataControlButton (ctrl, text,
image, command, argument, true));
return cell;
}
}
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -88,7 +88,7 @@
if (AutoPostBack){
writer.AddAttribute
(HtmlTextWriterAttribute.Onclick,
-
Page.GetPostBackClientEvent (this, ""));
+
Page.ClientScript.GetPostBackClientEvent (this, ""));
writer.AddAttribute ("language", "javascript");
}
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -256,7 +256,7 @@
if (AutoPostBack && Page != null){
writer.AddAttribute
(HtmlTextWriterAttribute.Onchange,
-
Page.GetPostBackClientEvent (this, ""));
+
Page.ClientScript.GetPostBackClientEvent (this, ""));
writer.AddAttribute ("language", "javascript");
}
}
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/TreeView.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/TreeView.cs
2005-03-11 13:24:59 UTC (rev 41697)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/TreeView.cs
2005-03-11 13:25:26 UTC (rev 41698)
@@ -887,7 +887,7 @@
base.OnPreRender (e);
if (EnableClientScript &&
!Page.ClientScript.IsClientScriptIncludeRegistered (typeof(TreeView),
"TreeView.js")) {
- string url = Page.GetWebResourceUrl
(typeof(TreeView), "TreeView.js");
+ string url =
Page.ClientScript.GetWebResourceUrl (typeof(TreeView), "TreeView.js");
Page.ClientScript.RegisterClientScriptInclude
(typeof(TreeView), "TreeView.js", url);
string ctree = ClientID + "_data";
@@ -908,15 +908,15 @@
script += string.Format
("{0}.populateFromClient = {1};\n", ctree, ClientScriptManager.GetScriptLiteral
(PopulateNodesFromClient));
script += string.Format ("{0}.expandAlt =
{1};\n", ctree, ClientScriptManager.GetScriptLiteral (GetNodeImageToolTip
(true, null)));
script += string.Format ("{0}.collapseAlt =
{1};\n", ctree, ClientScriptManager.GetScriptLiteral (GetNodeImageToolTip
(false, null)));
- Page.ClientScript.RegisterStartupScript
(typeof(TreeView), "", script, true);
+ Page.ClientScript.RegisterStartupScript
(typeof(TreeView), this.UniqueID, script, true);
}
if (EnableClientScript) {
Page.ClientScript.RegisterHiddenField (ClientID
+ "_ExpandStates", GetExpandStates ());
// Make sure the basic script infrastructure is
rendered
- Page.GetCallbackEventReference (this, "null", "",
"null");
- Page.GetPostBackClientHyperlink (this, "");
+ Page.ClientScript.GetCallbackEventReference (this,
"null", "", "null");
+ Page.ClientScript.GetPostBackClientHyperlink
(this, "");
}
if (dataBindings != null && dataBindings.Count > 0) {
@@ -1271,7 +1271,7 @@
string GetClientEvent (TreeNode node, string ev)
{
- return Page.GetPostBackClientHyperlink (this, ev + "|"
+ node.Path);
+ return Page.ClientScript.GetPostBackClientHyperlink
(this, ev + "|" + node.Path);
}
string GetClientExpandEvent (TreeNode node)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches