D:/Projects/Anthem/Anthem/FormView.cs

00001 #if V2
00002 
00003 using System;
00004 using System.ComponentModel;
00005 using System.Drawing;
00006 using System.Web.UI;
00007 using ASP = System.Web.UI.WebControls;
00008 
00009 namespace Anthem
00010 {
00014     [ToolboxBitmap(typeof(ASP.FormView))]
00015     public class FormView : ASP.FormView, 
00016         IUpdatableControl,
00017         ICallBackControl, 
00018         ICallBackContainerControl
00019     {
00020         #region Unique Anthem control code
00021 
00026         protected override void OnDataPropertyChanged()
00027         {
00028             base.OnDataPropertyChanged();
00029             UpdateAfterCallBack = true;
00030         }
00031 
00032         private const string parentTagName = "div";
00037         protected override void Render(HtmlTextWriter writer)
00038         {
00039 #if !V2
00040             bool DesignMode = this.Context == null;
00041 #endif
00042             if (EnableCallBack && AddCallBacks)
00043                 Anthem.Manager.AddCallBacks(this,
00044                     EnabledDuringCallBack,
00045                     TextDuringCallBack,
00046                     PreCallBackFunction,
00047                     PostCallBackFunction,
00048                     CallBackCancelledFunction);
00049 
00050             if (!DesignMode)
00051             {
00052                 Anthem.Manager.WriteBeginControlMarker(writer, parentTagName, this);
00053             }
00054             if (Visible)
00055             {
00056                 base.Render(writer);
00057             }
00058             if (!DesignMode)
00059             {
00060                 Anthem.Manager.WriteEndControlMarker(writer, parentTagName, this);
00061             }
00062         }
00063 
00064         #endregion
00065 
00066         #region ICallBackControl implementation
00067 
00072         [Category("Anthem")]
00073         [DefaultValue("")]
00074         [Description("The javascript function to call on the client if the callback is cancelled.")]
00075         public virtual string CallBackCancelledFunction
00076         {
00077             get
00078             {
00079                 string text = (string)ViewState["CallBackCancelledFunction"];
00080                 if (text == null)
00081                     return string.Empty;
00082                 else
00083                     return text;
00084             }
00085             set
00086             {
00087                 ViewState["CallBackCancelledFunction"] = value;
00088             }
00089         }
00090 
00098         [Category("Anthem")]
00099         [DefaultValue(true)]
00100         [Description("True if this control uses callbacks instead of postbacks to post data to the server.")]
00101         public virtual bool EnableCallBack
00102         {
00103             get
00104             {
00105                 object obj = this.ViewState["EnableCallBack"];
00106                 if (obj == null)
00107                     return true;
00108                 else
00109                     return (bool)obj;
00110             }
00111             set
00112             {
00113                 ViewState["EnableCallBack"] = value;
00114             }
00115         }
00116 
00125         [Category("Anthem")]
00126         [DefaultValue(true)]
00127         [Description("True if this control is enabled on the client during callbacks.")]
00128         public virtual bool EnabledDuringCallBack
00129         {
00130             get
00131             {
00132                 object obj = this.ViewState["EnabledDuringCallBack"];
00133                 if (obj == null)
00134                     return true;
00135                 else
00136                     return (bool)obj;
00137             }
00138             set
00139             {
00140                 ViewState["EnabledDuringCallBack"] = value;
00141             }
00142         }
00143 
00144 
00162         [Category("Anthem")]
00163         [DefaultValue("")]
00164         [Description("The javascript function to call on the client after the callback response is received.")]
00165         public virtual string PostCallBackFunction
00166         {
00167             get
00168             {
00169                 string text = (string)this.ViewState["PostCallBackFunction"];
00170                 if (text == null)
00171                 {
00172                     return string.Empty;
00173                 }
00174                 return text;
00175             }
00176             set
00177             {
00178                 ViewState["PostCallBackFunction"] = value;
00179             }
00180         }
00181 
00187         [Category("Anthem")]
00188         [DefaultValue("")]
00189         [Description("The javascript function to call on the client before the callback is made.")]
00190         public virtual string PreCallBackFunction
00191         {
00192             get
00193             {
00194                 string text = (string)this.ViewState["PreCallBackFunction"];
00195                 if (text == null)
00196                 {
00197                     return string.Empty;
00198                 }
00199                 return text;
00200             }
00201             set
00202             {
00203                 ViewState["PreCallBackFunction"] = value;
00204             }
00205         }
00206 
00215         [Category("Anthem")]
00216         [DefaultValue("")]
00217         [Description("The text to display during the callback.")]
00218         public virtual string TextDuringCallBack
00219         {
00220             get
00221             {
00222                 string text = (string)this.ViewState["TextDuringCallBack"];
00223                 if (text == null)
00224                 {
00225                     return string.Empty;
00226                 }
00227                 return text;
00228             }
00229             set
00230             {
00231                 ViewState["TextDuringCallBack"] = value;
00232             }
00233         }
00234 
00235         #endregion
00236 
00237         #region ICallBackContainerControl implementation
00238 
00250         [Category("Anthem")]
00251         [DefaultValue(true)]
00252         [Description("True if this control should convert child control postbacks into callbacks.")]
00253         public virtual bool AddCallBacks
00254         {
00255             get
00256             {
00257                 object obj = this.ViewState["AddCallBacks"];
00258                 if (obj == null)
00259                     return true;
00260                 else
00261                     return (bool)obj;
00262             }
00263             set
00264             {
00265                 ViewState["AddCallBacks"] = value;
00266             }
00267         }
00268 
00269         #endregion
00270 
00271         #region IUpdatableControl implementation
00272 
00286         [Category("Anthem")]
00287         [DefaultValue(false)]
00288         [Description("True if this control should be updated after each callback.")]
00289         public virtual bool AutoUpdateAfterCallBack
00290         {
00291             get
00292             {
00293                 object obj = this.ViewState["AutoUpdateAfterCallBack"];
00294                 if (obj == null)
00295                     return false;
00296                 else
00297                     return (bool)obj;
00298             }
00299             set
00300             {
00301                 if (value) UpdateAfterCallBack = true;
00302                 ViewState["AutoUpdateAfterCallBack"] = value;
00303             }
00304         }
00305 
00306         private bool _updateAfterCallBack = false;
00307 
00322         [Browsable(false)]
00323         [DefaultValue(false)]
00324         public virtual bool UpdateAfterCallBack
00325         {
00326             get { return _updateAfterCallBack; }
00327             set { _updateAfterCallBack = value; }
00328         }
00329 
00330         #endregion
00331 
00332         #region Common Anthem control code
00333 
00339         protected override void OnLoad(EventArgs e)
00340         {
00341             base.OnLoad(e);
00342             Anthem.Manager.Register(this);
00343         }
00344 
00345 #if V2
00349         public override void RenderControl(HtmlTextWriter writer)
00350         {
00351             base.Visible = true;
00352             base.RenderControl(writer);
00353         }
00354 #endif
00355 
00363         public override bool Visible
00364         {
00365             get
00366             {
00367 #if !V2
00368                 bool DesignMode = this.Context == null;
00369 #endif
00370                 return Anthem.Manager.GetControlVisible(this, ViewState, DesignMode);
00371             }
00372             set { Anthem.Manager.SetControlVisible(ViewState, value); }
00373         }
00374 
00375         #endregion
00376     }
00377 }
00378 
00379 #endif 

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