// Authors:
// Jackson Harper (jackson@ximian.com)
//
-// (C) 2005 Novell, Inc.
+// (C) 2005-2010 Novell, Inc.
//
using System.Collections.Specialized;
using System.ComponentModel;
using System.Security.Permissions;
+using System.Web.Util;
-namespace System.Web.UI.HtmlControls {
-
+namespace System.Web.UI.HtmlControls
+{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DefaultEvent("ServerClick")]
-#if NET_2_0
[SupportsEventValidation]
-#endif
- public class HtmlInputImage : HtmlInputControl, IPostBackDataHandler,
- IPostBackEventHandler {
-
- private static readonly object ServerClickEvent = new object ();
+ 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)]
[WebSysDescription("")]
[WebCategory("Behavior")]
-#if NET_2_0
- public virtual
-#else
- public
-#endif
- bool CausesValidation {
+ public virtual bool CausesValidation {
get {
return ViewState.GetBool ("CausesValidation", true);
}
[DefaultValue("")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-#if NET_2_0
[Localizable (true)]
-#endif
[WebSysDescription("")]
[WebCategory("Appearance")]
public string Alt {
[WebSysDescription("")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[WebCategory("Appearance")]
-#if NET_2_0
[UrlProperty]
-#endif
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")]
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 (x != null && x.Length != 0 &&
y != null && y.Length != 0) {
- clicked_x = Int32.Parse (x, CultureInfo.InvariantCulture);
- clicked_y = Int32.Parse (y, CultureInfo.InvariantCulture);
+ clicked_x = Int32.Parse (x, Helpers.InvariantCulture);
+ clicked_y = Int32.Parse (y, Helpers.InvariantCulture);
Page.RegisterRequiresRaiseEvent (this);
return true;
}
void RaisePostBackEventInternal (string eventArgument)
{
if (CausesValidation)
-#if NET_2_0
Page.Validate (ValidationGroup);
-#else
- Page.Validate ();
-#endif
+
OnServerClick (new ImageClickEventArgs (clicked_x, clicked_y));
}
/* no events to raise */
}
-#if NET_2_0
[DefaultValue ("")]
- public string ValidationGroup
+ public virtual string ValidationGroup
{
get {
return ViewState.GetString ("ValidationGroup", "");
protected virtual void RaisePostDataChangedEvent ()
{
+ ValidateEvent (UniqueID, String.Empty);
RaisePostDataChangedEventInternal ();
}
-#endif
- bool IPostBackDataHandler.LoadPostData (string postDataKey,
- NameValueCollection postCollection)
+ bool IPostBackDataHandler.LoadPostData (string postDataKey, NameValueCollection postCollection)
{
-#if NET_2_0
return LoadPostData (postDataKey, postCollection);
-#else
- return LoadPostDataInternal (postDataKey, postCollection);
-#endif
}
-
void IPostBackDataHandler.RaisePostDataChangedEvent ()
{
-#if NET_2_0
RaisePostDataChangedEvent();
-#else
- RaisePostDataChangedEventInternal ();
-#endif
}
void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
{
-#if NET_2_0
RaisePostBackEvent (eventArgument);
-#else
- RaisePostBackEventInternal (eventArgument);
-#endif
}
-#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)
}
}
}
-