D:/Projects/Anthem/Anthem/ImageButton.cs

00001 using System;
00002 using System.ComponentModel;
00003 using System.Drawing;
00004 using System.Web.UI;
00005 using ASP = System.Web.UI.WebControls;
00006 
00007 namespace Anthem
00008 {
00012     [ToolboxBitmap(typeof(ASP.ImageButton))]
00013     public class ImageButton : ASP.ImageButton, IUpdatableControl, ICallBackControl
00014     {
00015         #region Unique Anthem control code
00016 
00025         [Category("Anthem")]
00026         [DefaultValue("")]
00027         [Description("The text to display during the callback.")]
00028         public string ImageUrlDuringCallBack
00029         {
00030             get
00031             {
00032                 if (null == ViewState["ImageUrlDuringCallBack"])
00033                     return string.Empty;
00034                 else
00035                     return (string)ViewState["ImageUrlDuringCallBack"];
00036             }
00037             set { ViewState["ImageUrlDuringCallBack"] = value; }
00038         }
00039 
00044         protected override void AddAttributesToRender(HtmlTextWriter writer)
00045         {
00046             Anthem.Manager.AddScriptAttribute(
00047                 this,
00048                 "onclick",
00049                 Anthem.Manager.GetCallbackEventReference(
00050                     this,
00051                     this.CausesValidation,
00052 #if V2
00053                     this.ValidationGroup,
00054 #else
00055                     string.Empty,
00056 #endif
00057                     this.ImageUrlDuringCallBack == string.Empty ? string.Empty : this.ResolveUrl(this.ImageUrlDuringCallBack)
00058                 ) + "return false;"
00059             );
00060             base.AddAttributesToRender(writer);
00061         }
00062 
00063         private const string parentTagName = "span";
00068         protected override void Render(HtmlTextWriter writer)
00069         {
00070 #if !V2
00071             bool DesignMode = this.Context == null;
00072 #endif
00073             if (!DesignMode)
00074             {
00075                 // parentTagName must be defined as a private const string field in this class.
00076                 Anthem.Manager.WriteBeginControlMarker(writer, parentTagName, this);
00077             }
00078             if (Visible)
00079             {
00080                 base.Render(writer);
00081             }
00082             if (!DesignMode)
00083             {
00084                 Anthem.Manager.WriteEndControlMarker(writer, parentTagName, this);
00085             }
00086         }
00087 
00088         #endregion
00089 
00090         #region ICallBackControl implementation
00091 
00096         [Category("Anthem")]
00097         [DefaultValue("")]
00098         [Description("The javascript function to call on the client if the callback is cancelled.")]
00099         public virtual string CallBackCancelledFunction
00100         {
00101             get
00102             {
00103                 string text = (string)ViewState["CallBackCancelledFunction"];
00104                 if (text == null)
00105                     return string.Empty;
00106                 else
00107                     return text;
00108             }
00109             set
00110             {
00111                 ViewState["CallBackCancelledFunction"] = value;
00112             }
00113         }
00114 
00122         [Category("Anthem")]
00123         [DefaultValue(true)]
00124         [Description("True if this control uses callbacks instead of postbacks to post data to the server.")]
00125         public virtual bool EnableCallBack
00126         {
00127             get
00128             {
00129                 object obj = this.ViewState["EnableCallBack"];
00130                 if (obj == null)
00131                     return true;
00132                 else
00133                     return (bool)obj;
00134             }
00135             set
00136             {
00137                 ViewState["EnableCallBack"] = value;
00138             }
00139         }
00140 
00149         [Category("Anthem")]
00150         [DefaultValue(true)]
00151         [Description("True if this control is enabled on the client during callbacks.")]
00152         public virtual bool EnabledDuringCallBack
00153         {
00154             get
00155             {
00156                 object obj = this.ViewState["EnabledDuringCallBack"];
00157                 if (obj == null)
00158                     return true;
00159                 else
00160                     return (bool)obj;
00161             }
00162             set
00163             {
00164                 ViewState["EnabledDuringCallBack"] = value;
00165             }
00166         }
00167 
00168 
00186         [Category("Anthem")]
00187         [DefaultValue("")]
00188         [Description("The javascript function to call on the client after the callback response is received.")]
00189         public virtual string PostCallBackFunction
00190         {
00191             get
00192             {
00193                 string text = (string)this.ViewState["PostCallBackFunction"];
00194                 if (text == null)
00195                 {
00196                     return string.Empty;
00197                 }
00198                 return text;
00199             }
00200             set
00201             {
00202                 ViewState["PostCallBackFunction"] = value;
00203             }
00204         }
00205 
00211         [Category("Anthem")]
00212         [DefaultValue("")]
00213         [Description("The javascript function to call on the client before the callback is made.")]
00214         public virtual string PreCallBackFunction
00215         {
00216             get
00217             {
00218                 string text = (string)this.ViewState["PreCallBackFunction"];
00219                 if (text == null)
00220                 {
00221                     return string.Empty;
00222                 }
00223                 return text;
00224             }
00225             set
00226             {
00227                 ViewState["PreCallBackFunction"] = value;
00228             }
00229         }
00230 
00239         [Category("Anthem")]
00240         [DefaultValue("")]
00241         [Description("The text to display during the callback.")]
00242         public virtual string TextDuringCallBack
00243         {
00244             get
00245             {
00246                 string text = (string)this.ViewState["TextDuringCallBack"];
00247                 if (text == null)
00248                 {
00249                     return string.Empty;
00250                 }
00251                 return text;
00252             }
00253             set
00254             {
00255                 ViewState["TextDuringCallBack"] = value;
00256             }
00257         }
00258 
00259         #endregion
00260 
00261         #region IUpdatableControl implementation
00262 
00276         [Category("Anthem")]
00277         [DefaultValue(false)]
00278         [Description("True if this control should be updated after each callback.")]
00279         public virtual bool AutoUpdateAfterCallBack
00280         {
00281             get
00282             {
00283                 object obj = this.ViewState["AutoUpdateAfterCallBack"];
00284                 if (obj == null)
00285                     return false;
00286                 else
00287                     return (bool)obj;
00288             }
00289             set
00290             {
00291                 if (value) UpdateAfterCallBack = true;
00292                 ViewState["AutoUpdateAfterCallBack"] = value;
00293             }
00294         }
00295 
00296         private bool _updateAfterCallBack = false;
00297 
00312         [Browsable(false)]
00313         [DefaultValue(false)]
00314         public virtual bool UpdateAfterCallBack
00315         {
00316             get { return _updateAfterCallBack; }
00317             set { _updateAfterCallBack = value; }
00318         }
00319 
00320         #endregion
00321 
00322         #region Common Anthem control code
00323 
00329         protected override void OnLoad(EventArgs e)
00330         {
00331             base.OnLoad(e);
00332             Anthem.Manager.Register(this);
00333         }
00334 
00335 #if V2
00339         public override void RenderControl(HtmlTextWriter writer)
00340         {
00341             base.Visible = true;
00342             base.RenderControl(writer);
00343         }
00344 #endif
00345 
00353         public override bool Visible
00354         {
00355             get
00356             {
00357 #if !V2
00358                 bool DesignMode = this.Context == null;
00359 #endif
00360                 return Anthem.Manager.GetControlVisible(this, ViewState, DesignMode);
00361             }
00362             set { Anthem.Manager.SetControlVisible(ViewState, value); }
00363         }
00364 
00365         #endregion
00366     }
00367 }

Generated on Wed Mar 14 23:50:39 2007 for Anthem by  doxygen 1.5.1-p1