[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DefaultEvent("ServerClick")]
+#if NET_2_0
+ [SupportsEventValidation]
+#endif
public class HtmlInputImage : HtmlInputControl, IPostBackDataHandler,
IPostBackEventHandler {
[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 ("")]
- public string ValidationGroup
+ public virtual string ValidationGroup
{
get {
return ViewState.GetString ("ValidationGroup", "");
protected override void RenderAttributes (HtmlTextWriter writer)
{
+#if NET_2_0
+ if (Page != null)
+ Page.ClientScript.RegisterForEventValidation (this.UniqueID);
+
+ if (CausesValidation && Page != null && Page.AreValidatorsUplevel (ValidationGroup)) {
+ ClientScriptManager csm = Page.ClientScript;
+ Attributes ["onclick"] += csm.GetClientValidationEvent (ValidationGroup);
+ }
+#else
if (CausesValidation && Page != null && Page.AreValidatorsUplevel ()) {
ClientScriptManager csm = new ClientScriptManager (Page);
writer.WriteAttribute ("onclick", csm.GetClientValidationEvent ());
}
+#endif
base.RenderAttributes (writer);
}
private void SetAtt (string name, string value)
{
- if (value == null)
+ if ((value == null) || (value.Length == 0))
Attributes.Remove (name);
else
Attributes [name] = value;