D:/Projects/Anthem/Anthem/CheckBox.cs

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

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