// Authors:
// Jackson Harper (jackson@ximian.com)
//
-// (C) 2005 Novell, Inc.
+// (C) 2005-2010 Novell, Inc.
//
// TODO: getting the .x and .y in LoadData doesn't work with mozilla
//
-using System;
using System.Globalization;
using System.Collections.Specialized;
using System.ComponentModel;
-
-namespace System.Web.UI.HtmlControls {
+using System.Security.Permissions;
+using System.Web.Util;
+
+namespace System.Web.UI.HtmlControls
+{
+ // CAS
+ [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ // attributes
[DefaultEvent("ServerClick")]
- public class HtmlInputImage : HtmlInputControl, IPostBackDataHandler,
- IPostBackEventHandler {
-
- private static readonly object ServerClickEvent = new object ();
+ [SupportsEventValidation]
+ public class HtmlInputImage : HtmlInputControl, IPostBackDataHandler, IPostBackEventHandler
+ {
+ static readonly object ServerClickEvent = new object ();
- private int clicked_x;
- private int clicked_y;
+ int clicked_x;
+ int clicked_y;
public HtmlInputImage () : base ("image")
{
}
[DefaultValue(true)]
-#if NET_2_0
- public virtual
-#else
- public
-#endif
- bool CausesValidation {
+ [WebSysDescription("")]
+ [WebCategory("Behavior")]
+ public virtual bool CausesValidation {
get {
return ViewState.GetBool ("CausesValidation", true);
}
[DefaultValue("")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [WebSysDescription("")]
+ [WebCategory("Appearance")]
public string Align {
get { return GetAtt ("align"); }
set { SetAtt ("align", value); }
[DefaultValue("")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-#if NET_2_0
[Localizable (true)]
-#endif
+ [WebSysDescription("")]
+ [WebCategory("Appearance")]
public string Alt {
get { return GetAtt ("alt"); }
set { SetAtt ("alt", value); }
}
[DefaultValue("")]
+ [WebSysDescription("")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [WebCategory("Appearance")]
+ [UrlProperty]
public string Src {
get { return GetAtt ("src"); }
set { SetAtt ("src", value); }
}
-#if NET_2_0
[DefaultValue("-1")]
-#else
- [DefaultValue("")]
-#endif
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [WebSysDescription("")]
+ [WebCategory("Appearance")]
public int Border {
get {
string border = Attributes ["border"];
if (border == null)
return -1;
- return Int32.Parse (border, CultureInfo.InvariantCulture);
+ return Int32.Parse (border, Helpers.InvariantCulture);
}
set {
if (value == -1) {
Attributes.Remove ("border");
return;
}
- Attributes ["border"] = value.ToString (CultureInfo.InvariantCulture);
+ Attributes ["border"] = value.ToString (Helpers.InvariantCulture);
}
}
-#if NET_2_0
- [MonoTODO]
+ bool LoadPostDataInternal (string postDataKey, NameValueCollection postCollection)
+ {
+ string x = postCollection [UniqueID + ".x"];
+ string y = postCollection [UniqueID + ".y"];
+
+ if (x != null && x.Length != 0 &&
+ y != null && y.Length != 0) {
+ clicked_x = Int32.Parse (x, Helpers.InvariantCulture);
+ clicked_y = Int32.Parse (y, Helpers.InvariantCulture);
+ Page.RegisterRequiresRaiseEvent (this);
+ return true;
+ }
+
+ return false;
+ }
+
+
+ void RaisePostBackEventInternal (string eventArgument)
+ {
+ if (CausesValidation)
+ Page.Validate (ValidationGroup);
+
+ OnServerClick (new ImageClickEventArgs (clicked_x, clicked_y));
+ }
+
+ void RaisePostDataChangedEventInternal ()
+ {
+ /* no events to raise */
+ }
+
[DefaultValue ("")]
- public string ValidationGroup
+ public virtual string ValidationGroup
{
get {
- throw new NotImplementedException ();
+ return ViewState.GetString ("ValidationGroup", "");
}
set {
- throw new NotImplementedException ();
+ ViewState ["ValidationGroup"] = value;
}
}
- [MonoTODO]
protected virtual bool LoadPostData (string postDataKey, NameValueCollection postCollection)
{
- throw new NotImplementedException ();
+ return LoadPostDataInternal (postDataKey, postCollection);
}
- [MonoTODO]
- protected virtual void RaisePostBackEvent ()
+ protected virtual void RaisePostBackEvent (string eventArgument)
{
- throw new NotImplementedException ();
+ RaisePostBackEventInternal (eventArgument);
}
- [MonoTODO]
protected virtual void RaisePostDataChangedEvent ()
{
- throw new NotImplementedException ();
+ ValidateEvent (UniqueID, String.Empty);
+ RaisePostDataChangedEventInternal ();
}
-#endif
- bool IPostBackDataHandler.LoadPostData (string postDataKey,
- NameValueCollection postCollection)
+ bool IPostBackDataHandler.LoadPostData (string postDataKey, NameValueCollection postCollection)
{
- string x = postCollection [UniqueID + ".x"];
- string y = postCollection [UniqueID + ".y"];
-
- if (x != null && x.Length != 0 &&
- y != null && y.Length != 0) {
- clicked_x = Int32.Parse (x, CultureInfo.InvariantCulture);
- clicked_y = Int32.Parse (y, CultureInfo.InvariantCulture);
- Page.RegisterRequiresRaiseEvent (this);
- return true;
- }
-
- return false;
+ return LoadPostData (postDataKey, postCollection);
}
-
void IPostBackDataHandler.RaisePostDataChangedEvent ()
{
+ RaisePostDataChangedEvent();
}
void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
{
- if (CausesValidation)
- Page.Validate ();
- OnServerClick (new ImageClickEventArgs (clicked_x, clicked_y));
+ RaisePostBackEvent (eventArgument);
}
-#if NET_2_0
- protected internal
-#else
- protected
-#endif
- override void OnPreRender (EventArgs e)
+ protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
- if (Page != null)
- Page.RegisterRequiresPostBack (this);
+
+ Page page = Page;
+ if (page != null && !Disabled) {
+ page.RegisterRequiresPostBack (this);
+ page.RegisterEnabledControl (this);
+ }
}
protected virtual void OnServerClick (ImageClickEventArgs e)
{
- EventHandler handler = Events [ServerClickEvent] as EventHandler;
+ ImageClickEventHandler handler = Events [ServerClickEvent] as ImageClickEventHandler;
if (handler != null)
handler (this, e);
}
protected override void RenderAttributes (HtmlTextWriter writer)
{
- if (CausesValidation && Page != null && Page.AreValidatorsUplevel ()) {
- ClientScriptManager csm = new ClientScriptManager (Page);
- writer.WriteAttribute ("onclick", csm.GetClientValidationEvent ());
+ Page page = Page;
+ if (page != null)
+ page.ClientScript.RegisterForEventValidation (UniqueID);
+
+ if (CausesValidation && page != null && page.AreValidatorsUplevel (ValidationGroup)) {
+ ClientScriptManager csm = page.ClientScript;
+ Attributes ["onclick"] += csm.GetClientValidationEvent (ValidationGroup);
}
+ PreProcessRelativeReference (writer,"src");
base.RenderAttributes (writer);
}
- private void SetAtt (string name, string value)
+ void SetAtt (string name, string value)
{
- if (value == null)
+ if ((value == null) || (value.Length == 0))
Attributes.Remove (name);
else
Attributes [name] = value;
}
- private string GetAtt (string name)
+ string GetAtt (string name)
{
string res = Attributes [name];
if (res == null)
return res;
}
+ [WebSysDescription("")]
+ [WebCategory("Action")]
public event ImageClickEventHandler ServerClick {
add { Events.AddHandler (ServerClickEvent, value); }
remove { Events.AddHandler (ServerClickEvent, value); }
}
}
}
-