D:/Projects/Anthem/Anthem/DropDownList.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.DropDownList))]
00013     public class DropDownList : ASP.DropDownList, 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 AddAttributesToRender(HtmlTextWriter writer)
00039         {
00040             if (AutoCallBack)
00041             {
00042                 Anthem.Manager.AddScriptAttribute(
00043                     this,
00044                     "onchange",
00045                     Anthem.Manager.GetCallbackEventReference(
00046                         this,
00047 #if V2
00048                         this.CausesValidation,
00049                         this.ValidationGroup
00050 #else
00051                         false,
00052                         string.Empty
00053 #endif
00054                     ) + "return false;"
00055                 );
00056             }
00057             base.AddAttributesToRender(writer);
00058         }
00059 
00060 #if V2
00066         [Category("Default")]
00067         [DefaultValue("")]
00068         [MergableProperty(false)]
00069         [PersistenceMode(PersistenceMode.InnerDefaultProperty)]
00070         public new ASP.ListItemCollection Items
00071         {
00072             get
00073             {
00074                 return base.Items;
00075             }
00076         }
00077 #endif
00078 
00079         private const string parentTagName = "span";
00084         protected override void Render(HtmlTextWriter writer)
00085         {
00086 #if !V2
00087             bool DesignMode = this.Context == null;
00088 #endif
00089             if (!DesignMode)
00090             {
00091                 // parentTagName must be defined as a private const string field in this class.
00092                 Anthem.Manager.WriteBeginControlMarker(writer, parentTagName, this);
00093             }
00094             if (Visible)
00095             {
00096                 base.Render(writer);
00097             }
00098             if (!DesignMode)
00099             {
00100                 Anthem.Manager.WriteEndControlMarker(writer, parentTagName, this);
00101             }
00102         }
00103 
00104         #endregion
00105 
00106         #region ICallBackControl implementation
00107 
00112         [Category("Anthem")]
00113         [DefaultValue("")]
00114         [Description("The javascript function to call on the client if the callback is cancelled.")]
00115         public virtual string CallBackCancelledFunction
00116         {
00117             get
00118             {
00119                 string text = (string)ViewState["CallBackCancelledFunction"];
00120                 if (text == null)
00121                     return string.Empty;
00122                 else
00123                     return text;
00124             }
00125             set
00126             {
00127                 ViewState["CallBackCancelledFunction"] = value;
00128             }
00129         }
00130 
00138         [Category("Anthem")]
00139         [DefaultValue(true)]
00140         [Description("True if this control uses callbacks instead of postbacks to post data to the server.")]
00141         public virtual bool EnableCallBack
00142         {
00143             get
00144             {
00145                 object obj = this.ViewState["EnableCallBack"];
00146                 if (obj == null)
00147                     return true;
00148                 else
00149                     return (bool)obj;
00150             }
00151             set
00152             {
00153                 ViewState["EnableCallBack"] = value;
00154             }
00155         }
00156 
00165         [Category("Anthem")]
00166         [DefaultValue(true)]
00167         [Description("True if this control is enabled on the client during callbacks.")]
00168         public virtual bool EnabledDuringCallBack
00169         {
00170             get
00171             {
00172                 object obj = this.ViewState["EnabledDuringCallBack"];
00173                 if (obj == null)
00174                     return true;
00175                 else
00176                     return (bool)obj;
00177             }
00178             set
00179             {
00180                 ViewState["EnabledDuringCallBack"] = value;
00181             }
00182         }
00183 
00184 
00202         [Category("Anthem")]
00203         [DefaultValue("")]
00204         [Description("The javascript function to call on the client after the callback response is received.")]
00205         public virtual string PostCallBackFunction
00206         {
00207             get
00208             {
00209                 string text = (string)this.ViewState["PostCallBackFunction"];
00210                 if (text == null)
00211                 {
00212                     return string.Empty;
00213                 }
00214                 return text;
00215             }
00216             set
00217             {
00218                 ViewState["PostCallBackFunction"] = value;
00219             }
00220         }
00221 
00227         [Category("Anthem")]
00228         [DefaultValue("")]
00229         [Description("The javascript function to call on the client before the callback is made.")]
00230         public virtual string PreCallBackFunction
00231         {
00232             get
00233             {
00234                 string text = (string)this.ViewState["PreCallBackFunction"];
00235                 if (text == null)
00236                 {
00237                     return string.Empty;
00238                 }
00239                 return text;
00240             }
00241             set
00242             {
00243                 ViewState["PreCallBackFunction"] = value;
00244             }
00245         }
00246 
00255         [Category("Anthem")]
00256         [DefaultValue("")]
00257         [Description("The text to display during the callback.")]
00258         public virtual string TextDuringCallBack
00259         {
00260             get
00261             {
00262                 string text = (string)this.ViewState["TextDuringCallBack"];
00263                 if (text == null)
00264                 {
00265                     return string.Empty;
00266                 }
00267                 return text;
00268             }
00269             set
00270             {
00271                 ViewState["TextDuringCallBack"] = value;
00272             }
00273         }
00274 
00275         #endregion
00276 
00277         #region IUpdatableControl implementation
00278 
00292         [Category("Anthem")]
00293         [DefaultValue(false)]
00294         [Description("True if this control should be updated after each callback.")]
00295         public virtual bool AutoUpdateAfterCallBack
00296         {
00297             get
00298             {
00299                 object obj = this.ViewState["AutoUpdateAfterCallBack"];
00300                 if (obj == null)
00301                     return false;
00302                 else
00303                     return (bool)obj;
00304             }
00305             set
00306             {
00307                 if (value) UpdateAfterCallBack = true;
00308                 ViewState["AutoUpdateAfterCallBack"] = value;
00309             }
00310         }
00311 
00312         private bool _updateAfterCallBack = false;
00313 
00328         [Browsable(false)]
00329         [DefaultValue(false)]
00330         public virtual bool UpdateAfterCallBack
00331         {
00332             get { return _updateAfterCallBack; }
00333             set { _updateAfterCallBack = value; }
00334         }
00335 
00336         #endregion
00337 
00338         #region Common Anthem control code
00339 
00345         protected override void OnLoad(EventArgs e)
00346         {
00347             base.OnLoad(e);
00348             Anthem.Manager.Register(this);
00349         }
00350 
00351 #if V2
00355         public override void RenderControl(HtmlTextWriter writer)
00356         {
00357             base.Visible = true;
00358             base.RenderControl(writer);
00359         }
00360 #endif
00361 
00369         public override bool Visible
00370         {
00371             get
00372             {
00373 #if !V2
00374                 bool DesignMode = this.Context == null;
00375 #endif
00376                 return Anthem.Manager.GetControlVisible(this, ViewState, DesignMode);
00377             }
00378             set { Anthem.Manager.SetControlVisible(ViewState, value); }
00379         }
00380 
00381         #endregion
00382     }
00383 }

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