// Authors:
// Lluis Sanchez Gual (lluis@novell.com)
//
-// (C) 2005 Novell, Inc (http://www.novell.com)
+// (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
//
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
-
using System.ComponentModel;
using System.Security.Permissions;
[DefaultEvent ("Click")]
[AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ [SupportsEventValidation]
public class ImageMap: Image, IPostBackEventHandler
{
HotSpotCollection spots;
- private static readonly object ClickEvent = new object();
+ static readonly object ClickEvent = new object();
[Category ("Action")]
- public event ImageMapEventHandler Click
- {
+ public event ImageMapEventHandler Click {
add { Events.AddHandler (ClickEvent, value); }
remove { Events.RemoveHandler (ClickEvent, value); }
}
{
if (Events != null) {
ImageMapEventHandler eh = (ImageMapEventHandler) Events [ClickEvent];
- if (eh!= null) eh (this, e);
+ if (eh!= null)
+ eh (this, e);
}
}
- [DefaultValueAttribute (HotSpotMode.NotSet)]
+ // Why override?
+ [Browsable (true)]
+ [EditorBrowsable (EditorBrowsableState.Always)]
+ public override bool Enabled {
+ get { return base.Enabled; }
+ set { base.Enabled = value; }
+ }
+
+ [DefaultValueAttribute (HotSpotMode.NotSet)]
public virtual HotSpotMode HotSpotMode {
get {
object o = ViewState ["HotSpotMode"];
return o != null ? (HotSpotMode) o : HotSpotMode.NotSet;
}
- set {
- ViewState ["HotSpotMode"] = value;
- }
+ set { ViewState ["HotSpotMode"] = value; }
}
- [DefaultValueAttribute ("")]
+ [DefaultValueAttribute ("")]
public virtual string Target {
get {
object o = ViewState ["Target"];
- return o != null ? (string) o : "";
- }
- set {
- ViewState ["Target"] = value;
+ return o != null ? (string) o : String.Empty;
}
+ set { ViewState ["Target"] = value; }
}
- [NotifyParentPropertyAttribute (true)]
- [PersistenceModeAttribute (PersistenceMode.InnerDefaultProperty)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
+ [NotifyParentPropertyAttribute (true)]
+ [PersistenceModeAttribute (PersistenceMode.InnerDefaultProperty)]
+ [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
public HotSpotCollection HotSpots {
get {
if (spots == null) {
protected override void TrackViewState ()
{
base.TrackViewState ();
- if (spots != null) ((IStateManager)spots).TrackViewState ();
+ if (spots != null)
+ ((IStateManager)spots).TrackViewState ();
}
protected override object SaveViewState ()
base.LoadViewState (pair.First);
((IStateManager)HotSpots).LoadViewState (pair.Second);
}
-
- public void RaisePostBackEvent (string eventArgument)
+
+ protected virtual void RaisePostBackEvent (string eventArgument)
{
+ ValidateEvent (UniqueID, eventArgument);
HotSpot spot = HotSpots [int.Parse (eventArgument)];
OnClick (new ImageMapEventArgs (spot.PostBackValue));
}
+ void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
+ {
+ RaisePostBackEvent (eventArgument);
+ }
+
protected override void AddAttributesToRender (HtmlTextWriter writer)
{
base.AddAttributesToRender (writer);
base.Render (writer);
if (spots != null && spots.Count > 0) {
+ bool enabled = Enabled;
+ writer.AddAttribute (HtmlTextWriterAttribute.Id, "ImageMap" + ClientID);
writer.AddAttribute (HtmlTextWriterAttribute.Name, "ImageMap" + ClientID);
writer.RenderBeginTag (HtmlTextWriterTag.Map);
for (int n=0; n<spots.Count; n++) {
HotSpotMode mode = spot.HotSpotMode != HotSpotMode.NotSet ? spot.HotSpotMode : HotSpotMode;
switch (mode) {
case HotSpotMode.Inactive:
- writer.AddAttribute ("nohref", "true");
+ writer.AddAttribute ("nohref", "true", false);
break;
case HotSpotMode.Navigate:
string target = spot.Target.Length > 0 ? spot.Target : Target;
if (!String.IsNullOrEmpty (target))
writer.AddAttribute (HtmlTextWriterAttribute.Target, target);
- writer.AddAttribute (HtmlTextWriterAttribute.Href, spot.NavigateUrl);
+ if (enabled) {
+ string navUrl = ResolveClientUrl (spot.NavigateUrl);
+ writer.AddAttribute (HtmlTextWriterAttribute.Href, navUrl);
+ }
break;
case HotSpotMode.PostBack:
- writer.AddAttribute (HtmlTextWriterAttribute.Href, Page.ClientScript.GetPostBackClientHyperlink (this, n.ToString()));
+ writer.AddAttribute (HtmlTextWriterAttribute.Href, Page.ClientScript.GetPostBackClientHyperlink (this, n.ToString(), true));
break;
}
}
}
-#endif