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

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