2 // System.Web.UI.WebControls.HotSpot.cs
5 // Lluis Sanchez Gual (lluis@novell.com)
7 // (C) 2005 Novell, Inc (http://www.novell.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.ComponentModel;
34 using System.Security.Permissions;
36 namespace System.Web.UI.WebControls
38 [TypeConverterAttribute (typeof(ExpandableObjectConverter))]
39 [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
40 [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
41 public abstract class HotSpot: IStateManager
43 StateBag viewState = new StateBag ();
45 [LocalizableAttribute (true)]
46 [DefaultValueAttribute ("")]
47 public virtual string AccessKey {
49 object o = viewState ["AccessKey"];
50 return o != null ? (string) o : "";
53 if (value == null || value.Length < 2)
54 viewState ["AccessKey"] = value;
56 throw new ArgumentOutOfRangeException ("value", "AccessKey can only be null, empty or a single character");
60 [LocalizableAttribute (true)]
61 [NotifyParentPropertyAttribute (true)]
62 [WebCategoryAttribute ("Behavior")]
63 [DefaultValueAttribute ("")]
64 [BindableAttribute (true)]
65 public virtual string AlternateText {
67 object o = viewState ["AlternateText"];
68 return o != null ? (string) o : "";
71 viewState ["AlternateText"] = value;
75 [WebCategoryAttribute ("Behavior")]
76 [DefaultValueAttribute (HotSpotMode.NotSet)]
77 [NotifyParentPropertyAttribute (true)]
78 public virtual HotSpotMode HotSpotMode {
80 object o = viewState ["HotSpotMode"];
81 return o != null ? (HotSpotMode) o : HotSpotMode.NotSet;
84 if ((int) value < 0 || (int) value > 3)
85 throw new ArgumentOutOfRangeException ("value");
86 viewState ["HotSpotMode"] = value;
90 [DefaultValueAttribute ("")]
91 [BindableAttribute (true)]
92 [EditorAttribute ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
93 [NotifyParentPropertyAttribute (true)]
94 [UrlPropertyAttribute]
95 public string NavigateUrl {
97 object o = viewState ["NavigateUrl"];
98 return o != null ? (string) o : "";
101 viewState ["NavigateUrl"] = value;
105 [BindableAttribute (true)]
106 [WebCategoryAttribute ("Behavior")]
107 [DefaultValueAttribute ("")]
108 [NotifyParentPropertyAttribute (true)]
109 public string PostBackValue {
111 object o = viewState ["PostBackValue"];
112 return o != null ? (string) o : "";
115 viewState ["PostBackValue"] = value;
119 [DefaultValueAttribute ((short)0)]
120 [WebCategoryAttribute ("Accessibility")]
121 public virtual short TabIndex {
123 object o = viewState ["TabIndex"];
124 return o != null ? (short) o : (short) 0;
127 viewState ["TabIndex"] = value;
131 [WebCategoryAttribute ("Behavior")]
132 [NotifyParentPropertyAttribute (true)]
133 [DefaultValueAttribute ("")]
134 [TypeConverterAttribute (typeof(TargetConverter))]
135 public virtual string Target {
137 object o = viewState ["Target"];
138 return o != null ? (string) o : "";
141 viewState ["Target"] = value;
146 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
147 protected StateBag ViewState {
148 get { return viewState; }
151 protected virtual void LoadViewState (object savedState)
153 viewState.LoadViewState (savedState);
156 protected virtual object SaveViewState ()
158 return viewState.SaveViewState ();
161 protected virtual void TrackViewState ()
163 viewState.TrackViewState ();
166 protected virtual bool IsTrackingViewState
168 get { return viewState.IsTrackingViewState; }
171 void IStateManager.LoadViewState (object savedState)
173 LoadViewState (savedState);
176 object IStateManager.SaveViewState ()
178 return SaveViewState ();
181 void IStateManager.TrackViewState ()
186 bool IStateManager.IsTrackingViewState
188 get { return IsTrackingViewState; }
191 public override string ToString ()
193 return GetType().Name;
196 internal void SetDirty ()
198 viewState.SetDirty (true);
201 public abstract string GetCoordinates ();
203 protected internal abstract string MarkupName { get; }