瀏覽代碼

MenuItem.cs: bind to NavigateUrl; CompositeDataBoundControl.cs: ensures data is bound; Menu.cs: fixed binding

svn path=/trunk/mcs/; revision=59687
Konstantin Triger 19 年之前
父節點
當前提交
bfd8d4d62e

+ 11 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,14 @@
+2006-04-20  Konstantin Triger  <[email protected]>
+
+	* MenuItem.cs: when binding to IHierarchyData, check whether 
+		it implements INavigateUIData and retrieve NavigateUrl.
+	* CompositeDataBoundControl.cs: ensures data is bound before creating child controls.
+	* Menu.cs:
+		Enable DataBinding by not throwing NotImplementedException in OnDataBound event. 
+		Provide basic CreateChildControls implementation by ensuring the control is bound. 
+		Ensure the child controls are created when the postback event is raised. 
+		Provide default implementation for SkipLinkText to let the default functionality to work.
+
 2006-04-11  Lluis Sanchez  <[email protected]>
 
 	* TreeNodeBinding.cs: Added HasPropertyValue property

+ 5 - 2
mcs/class/System.Web/System.Web.UI.WebControls/CompositeDataBoundControl.cs

@@ -53,10 +53,13 @@ namespace System.Web.UI.WebControls
 		{
 			base.CreateChildControls ();
 
-			if (Page.IsPostBack) {
-				object[] data = new object [(int)ViewState ["_ItemCount"]];
+			object itemCount = ViewState ["_ItemCount"];
+			if (itemCount != null) {
+				object [] data = new object [(int) itemCount];
 				ViewState ["_ItemCount"] = CreateChildControls (data, false);
 			}
+			else
+				EnsureDataBound ();
 		}
 		
 		protected internal override void PerformDataBinding (IEnumerable data)

+ 19 - 11
mcs/class/System.Web/System.Web.UI.WebControls/Menu.cs

@@ -99,10 +99,10 @@ namespace System.Web.UI.WebControls
 			}
 		}
 
-	    [DefaultValueAttribute (null)]
+	    [DefaultValueAttribute (null)]
 		[PersistenceMode (PersistenceMode.InnerProperty)]
-	    [EditorAttribute ("System.Web.UI.Design.WebControls.MenuBindingsEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
-	    [MergablePropertyAttribute (false)]
+	    [EditorAttribute ("System.Web.UI.Design.WebControls.MenuBindingsEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
+	    [MergablePropertyAttribute (false)]
 		public MenuItemBindingCollection DataBindings {
 			get {
 				if (dataBindings == null) {
@@ -142,7 +142,7 @@ namespace System.Web.UI.WebControls
 			}
 		}
 
-	    [DefaultValueAttribute ("")]
+	    [DefaultValueAttribute ("")]
 		public string DynamicItemFormatString {
 			get {
 				object o = ViewState ["DynamicItemFormatString"];
@@ -225,7 +225,7 @@ namespace System.Web.UI.WebControls
 			}
 		}
 
-	    [DefaultValueAttribute ("")]
+	    [DefaultValueAttribute ("")]
 		public string StaticItemFormatString {
 			get {
 				object o = ViewState ["StaticItemFormatString"];
@@ -670,11 +670,14 @@ namespace System.Web.UI.WebControls
 		[Localizable (true)]
 		public string SkipLinkText 
 		{
-			get {
-				throw new NotImplementedException ();
+			get {
+				object o = ViewState ["SkipLinkText"];
+				if (o != null)
+					return (string) o;
+				return String.Empty;
 			}
-			set {
-				throw new NotImplementedException ();
+			set {
+				ViewState ["SkipLinkText"] = value;
 			}
 		}
 		
@@ -760,6 +763,10 @@ namespace System.Web.UI.WebControls
 		
 		protected internal virtual void RaisePostBackEvent (string eventArgument)
 		{
+			if (!Enabled)
+				return;
+
+			EnsureChildControls();
 			MenuItem item = FindItemByPos (eventArgument);
 			if (item == null) return;
 			item.Selected = true;
@@ -917,7 +924,8 @@ namespace System.Web.UI.WebControls
 		
 		protected internal override void CreateChildControls ()
 		{
-			base.CreateChildControls ();
+			Controls.Clear ();
+			EnsureDataBound ();
 		}
 		
 		protected override void EnsureDataBound ()
@@ -955,7 +963,7 @@ namespace System.Web.UI.WebControls
 		[MonoTODO]
 		protected override void OnDataBinding (EventArgs e)
 		{
-			throw new NotImplementedException ();
+			base.OnDataBinding (e);
 		}
 		
 		protected internal override void OnPreRender (EventArgs e)

+ 7 - 4
mcs/class/System.Web/System.Web.UI.WebControls/MenuItem.cs

@@ -352,8 +352,8 @@ namespace System.Web.UI.WebControls
 			}
 		}
 		
-	    [BrowsableAttribute (true)]
-	    [DefaultValueAttribute (true)]
+	    [BrowsableAttribute (true)]
+	    [DefaultValueAttribute (true)]
 		public bool Selectable {
 			get {
 				object o = ViewState ["Selectable"];
@@ -373,8 +373,8 @@ namespace System.Web.UI.WebControls
 			}
 		}
 		
-	    [BrowsableAttribute (true)]
-	    [DefaultValueAttribute (true)]
+	    [BrowsableAttribute (true)]
+	    [DefaultValueAttribute (true)]
 		public bool Enabled {
 			get {
 				object o = ViewState ["Enabled"];
@@ -532,6 +532,9 @@ namespace System.Web.UI.WebControls
 			dataBound = true;
 			dataPath = hierarchyData.Path;
 			dataItem = hierarchyData.Item;
+			INavigateUIData navigateUIData = hierarchyData as INavigateUIData;
+			if (navigateUIData != null)
+				NavigateUrl = navigateUIData.NavigateUrl;
 		}
 		
 		internal void SetDataItem (object item)