2 // System.Web.UI.WebControls.MenuItemBinding.cs
5 // Lluis Sanchez Gual (lluis@novell.com)
7 // (C) 2004 Novell, Inc (http://www.novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
34 using System.Collections;
36 using System.ComponentModel;
38 namespace System.Web.UI.WebControls
40 [DefaultProperty ("TextField")]
41 public sealed class MenuItemBinding: IStateManager, ICloneable, IDataSourceViewSchemaAccessor
43 StateBag ViewState = new StateBag ();
46 public string DataMember {
48 object o = ViewState ["DataMember"];
49 if (o != null) return (string) o;
53 ViewState ["DataMember"] = value;
60 object o = ViewState ["Depth"];
61 if (o != null) return (int) o;
65 ViewState ["Depth"] = value;
72 object o = ViewState ["Enabled"];
73 if (o != null) return (bool) o;
77 ViewState ["Enabled"] = value;
82 [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
83 public string EnabledField {
85 object o = ViewState ["EnabledField"];
86 if (o != null) return (string) o;
90 ViewState ["EnabledField"] = value;
96 public string FormatString {
98 object o = ViewState ["FormatString"];
99 if (o != null) return (string) o;
103 ViewState ["FormatString"] = value;
109 [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
110 public string ImageUrl {
112 object o = ViewState ["ImageUrl"];
113 if (o != null) return (string) o;
117 ViewState ["ImageUrl"] = value;
122 [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
123 public string ImageUrlField {
125 object o = ViewState ["ImageUrlField"];
126 if (o != null) return (string) o;
130 ViewState ["ImageUrlField"] = value;
136 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
137 public string NavigateUrl {
139 object o = ViewState ["NavigateUrl"];
140 if (o != null) return (string) o;
144 ViewState ["NavigateUrl"] = value;
149 [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
150 public string NavigateUrlField {
152 object o = ViewState ["NavigateUrlField"];
153 if (o != null) return (string) o;
157 ViewState ["NavigateUrlField"] = value;
162 public string Target {
164 object o = ViewState ["Target"];
165 if(o != null) return (string)o;
169 ViewState ["Target"] = value;
174 [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
175 public string TargetField {
177 object o = ViewState ["TargetField"];
178 if (o != null) return (string) o;
182 ViewState ["TargetField"] = value;
188 [WebSysDescription ("The display text of the menu item.")]
191 object o = ViewState ["Text"];
192 if(o != null) return (string)o;
196 ViewState ["Text"] = value;
201 [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
202 public string TextField {
204 object o = ViewState ["TextField"];
205 if(o != null) return (string)o;
209 ViewState ["TextField"] = value;
215 public string ToolTip {
217 object o = ViewState ["ToolTip"];
218 if(o != null) return (string)o;
222 ViewState ["ToolTip"] = value;
227 [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
228 public string ToolTipField {
230 object o = ViewState ["ToolTipField"];
231 if(o != null) return (string)o;
235 ViewState ["ToolTipField"] = value;
241 public string Value {
243 object o = ViewState ["Value"];
244 if(o != null) return (string)o;
248 ViewState ["Value"] = value;
253 [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
254 public string ValueField {
256 object o = ViewState ["ValueField"];
257 if(o != null) return (string)o;
261 ViewState ["ValueField"] = value;
265 void IStateManager.LoadViewState (object savedState)
267 ViewState.LoadViewState (savedState);
270 object IStateManager.SaveViewState ()
272 return ViewState.SaveViewState();
275 void IStateManager.TrackViewState ()
277 ViewState.TrackViewState ();
280 bool IStateManager.IsTrackingViewState {
281 get { return ViewState.IsTrackingViewState; }
285 object IDataSourceViewSchemaAccessor.DataSourceViewSchema {
286 get { throw new NotImplementedException (); }
287 set { throw new NotImplementedException (); }
290 object ICloneable.Clone ()
292 MenuItemBinding bin = new MenuItemBinding ();
293 foreach (DictionaryEntry e in ViewState)
294 bin.ViewState [(string)e.Key] = e.Value;
298 internal void SetDirty ()
300 foreach (string key in ViewState.Keys)
301 ViewState.SetItemDirty (key, true);