D:/Projects/Anthem/Anthem/Repeater.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 {
00013     [ToolboxBitmap(typeof(ASP.Repeater))]
00014     public class Repeater : ASP.Repeater, IUpdatableControl, ICallBackContainerControl
00015     {
00016         #region Unique Anthem control code
00017 
00022         protected override void OnItemCommand(System.Web.UI.WebControls.RepeaterCommandEventArgs e)
00023         {
00024             base.OnItemCommand(e);
00025             this.UpdateAfterCallBack = true;
00026         }
00027 
00028         private const string parentTagName = "div";
00033         protected override void Render(HtmlTextWriter writer)
00034         {
00035 #if !V2
00036             bool DesignMode = this.Context == null;
00037 #endif
00038             if (EnableCallBack && AddCallBacks)
00039                 Anthem.Manager.AddCallBacks(this,
00040                     EnabledDuringCallBack,
00041                     TextDuringCallBack,
00042                     PreCallBackFunction,
00043                     PostCallBackFunction,
00044                     CallBackCancelledFunction);
00045 
00046             if (!DesignMode)
00047             {
00048                 Anthem.Manager.WriteBeginControlMarker(writer, parentTagName, this);
00049             }
00050             if (Visible)
00051             {
00052                 base.Render(writer);
00053             }
00054             if (!DesignMode)
00055             {
00056                 Anthem.Manager.WriteEndControlMarker(writer, parentTagName, this);
00057             }
00058         }
00059 
00060         #endregion
00061 
00062         #region ICallBackControl implementation
00063 
00068         [Category("Anthem")]
00069         [DefaultValue("")]
00070         [Description("The javascript function to call on the client if the callback is cancelled.")]
00071         public virtual string CallBackCancelledFunction
00072         {
00073             get
00074             {
00075                 string text = (string)ViewState["CallBackCancelledFunction"];
00076                 if (text == null)
00077                     return string.Empty;
00078                 else
00079                     return text;
00080             }
00081             set
00082             {
00083                 ViewState["CallBackCancelledFunction"] = value;
00084             }
00085         }
00086 
00094         [Category("Anthem")]
00095         [DefaultValue(true)]
00096         [Description("True if this control uses callbacks instead of postbacks to post data to the server.")]
00097         public virtual bool EnableCallBack
00098         {
00099             get
00100             {
00101                 object obj = this.ViewState["EnableCallBack"];
00102                 if (obj == null)
00103                     return true;
00104                 else
00105                     return (bool)obj;
00106             }
00107             set
00108             {
00109                 ViewState["EnableCallBack"] = value;
00110             }
00111         }
00112 
00121         [Category("Anthem")]
00122         [DefaultValue(true)]
00123         [Description("True if this control is enabled on the client during callbacks.")]
00124         public virtual bool EnabledDuringCallBack
00125         {
00126             get
00127             {
00128                 object obj = this.ViewState["EnabledDuringCallBack"];
00129                 if (obj == null)
00130                     return true;
00131                 else
00132                     return (bool)obj;
00133             }
00134             set
00135             {
00136                 ViewState["EnabledDuringCallBack"] = value;
00137             }
00138         }
00139 
00140 
00158         [Category("Anthem")]
00159         [DefaultValue("")]
00160         [Description("The javascript function to call on the client after the callback response is received.")]
00161         public virtual string PostCallBackFunction
00162         {
00163             get
00164             {
00165                 string text = (string)this.ViewState["PostCallBackFunction"];
00166                 if (text == null)
00167                 {
00168                     return string.Empty;
00169                 }
00170                 return text;
00171             }
00172             set
00173             {
00174                 ViewState["PostCallBackFunction"] = value;
00175             }
00176         }
00177 
00183         [Category("Anthem")]
00184         [DefaultValue("")]
00185         [Description("The javascript function to call on the client before the callback is made.")]
00186         public virtual string PreCallBackFunction
00187         {
00188             get
00189             {
00190                 string text = (string)this.ViewState["PreCallBackFunction"];
00191                 if (text == null)
00192                 {
00193                     return string.Empty;
00194                 }
00195                 return text;
00196             }
00197             set
00198             {
00199                 ViewState["PreCallBackFunction"] = value;
00200             }
00201         }
00202 
00211         [Category("Anthem")]
00212         [DefaultValue("")]
00213         [Description("The text to display during the callback.")]
00214         public virtual string TextDuringCallBack
00215         {
00216             get
00217             {
00218                 string text = (string)this.ViewState["TextDuringCallBack"];
00219                 if (text == null)
00220                 {
00221                     return string.Empty;
00222                 }
00223                 return text;
00224             }
00225             set
00226             {
00227                 ViewState["TextDuringCallBack"] = value;
00228             }
00229         }
00230 
00231         #endregion
00232 
00233         #region ICallBackContainerControl implementation
00234 
00246         [Category("Anthem")]
00247         [DefaultValue(true)]
00248         [Description("True if this control should convert child control postbacks into callbacks.")]
00249         public virtual bool AddCallBacks
00250         {
00251             get
00252             {
00253                 object obj = this.ViewState["AddCallBacks"];
00254                 if (obj == null)
00255                     return true;
00256                 else
00257                     return (bool)obj;
00258             }
00259             set
00260             {
00261                 ViewState["AddCallBacks"] = value;
00262             }
00263         }
00264 
00265         #endregion
00266 
00267         #region IUpdatableControl implementation
00268 
00282         [Category("Anthem")]
00283         [DefaultValue(false)]
00284         [Description("True if this control should be updated after each callback.")]
00285         public virtual bool AutoUpdateAfterCallBack
00286         {
00287             get
00288             {
00289                 object obj = this.ViewState["AutoUpdateAfterCallBack"];
00290                 if (obj == null)
00291                     return false;
00292                 else
00293                     return (bool)obj;
00294             }
00295             set
00296             {
00297                 if (value) UpdateAfterCallBack = true;
00298                 ViewState["AutoUpdateAfterCallBack"] = value;
00299             }
00300         }
00301 
00302         private bool _updateAfterCallBack = false;
00303 
00318         [Browsable(false)]
00319         [DefaultValue(false)]
00320         public virtual bool UpdateAfterCallBack
00321         {
00322             get { return _updateAfterCallBack; }
00323             set { _updateAfterCallBack = value; }
00324         }
00325 
00326         #endregion
00327 
00328         #region Common Anthem control code
00329 
00335         protected override void OnLoad(EventArgs e)
00336         {
00337             base.OnLoad(e);
00338             Anthem.Manager.Register(this);
00339         }
00340 
00341 #if V2
00345         public override void RenderControl(HtmlTextWriter writer)
00346         {
00347             base.Visible = true;
00348             base.RenderControl(writer);
00349         }
00350 #endif
00351 
00359         public override bool Visible
00360         {
00361             get
00362             {
00363 #if !V2
00364                 bool DesignMode = this.Context == null;
00365 #endif
00366                 return Anthem.Manager.GetControlVisible(this, ViewState, DesignMode);
00367             }
00368             set { Anthem.Manager.SetControlVisible(ViewState, value); }
00369         }
00370 
00371         #endregion
00372     }
00373 }

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