D:/Projects/Anthem/Anthem/BulletedList.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.BulletedList))]
00013     public class BulletedList : ASP.BulletedList, IUpdatableControl, ICallBackControl
00014     {
00015         #region Unique Anthem control code
00016 
00022         [Category("Default")]
00023         [DefaultValue("")]
00024         [MergableProperty(false)]
00025         [PersistenceMode(PersistenceMode.InnerProperty)]
00026         public override System.Web.UI.WebControls.ListItemCollection Items
00027         {
00028             get
00029             {
00030                 return base.Items;
00031             }
00032         }
00033 
00038         protected override void AddAttributesToRender(HtmlTextWriter writer)
00039         {
00040             base.AddAttributesToRender(writer);
00041             if (this.DisplayMode == ASP.BulletedListDisplayMode.LinkButton)
00042             {
00043                 for (int index = 0; index < this.Items.Count; index++)
00044                 {
00045                     ASP.ListItem item = this.Items[index];
00046                     Anthem.Manager.AddScriptAttribute(
00047                         this,
00048                         item,
00049                         "onclick",
00050                         Anthem.Manager.GetCallbackEventReference(
00051                             this,
00052                             index.ToString(),
00053                             this.CausesValidation,
00054                             this.ValidationGroup
00055                         ) + "return false;"
00056                     );
00057                 }
00058             }
00059         }
00060 
00061         private const string parentTagName = "div";
00066         protected override void Render(HtmlTextWriter writer)
00067         {
00068             if (!DesignMode)
00069             {
00070                 Anthem.Manager.WriteBeginControlMarker(writer, parentTagName, this);
00071             }
00072             if (Visible)
00073             {
00074                 base.Render(writer);
00075             }
00076             if (!DesignMode)
00077             {
00078                 Anthem.Manager.WriteEndControlMarker(writer, parentTagName, this);
00079             }
00080         }
00081 
00082         #endregion
00083 
00084         #region ICallBackControl implementation
00085 
00090         [Category("Anthem")]
00091         [DefaultValue("")]
00092         [Description("The javascript function to call on the client if the callback is cancelled.")]
00093         public virtual string CallBackCancelledFunction
00094         {
00095             get
00096             {
00097                 string text = (string)ViewState["CallBackCancelledFunction"];
00098                 if (text == null)
00099                     return string.Empty;
00100                 else
00101                     return text;
00102             }
00103             set
00104             {
00105                 ViewState["CallBackCancelledFunction"] = value;
00106             }
00107         }
00108 
00116         [Category("Anthem")]
00117         [DefaultValue(true)]
00118         [Description("True if this control uses callbacks instead of postbacks to post data to the server.")]
00119         public virtual bool EnableCallBack
00120         {
00121             get
00122             {
00123                 object obj = this.ViewState["EnableCallBack"];
00124                 if (obj == null)
00125                     return true;
00126                 else
00127                     return (bool)obj;
00128             }
00129             set
00130             {
00131                 ViewState["EnableCallBack"] = value;
00132             }
00133         }
00134 
00143         [Category("Anthem")]
00144         [DefaultValue(true)]
00145         [Description("True if this control is enabled on the client during callbacks.")]
00146         public virtual bool EnabledDuringCallBack
00147         {
00148             get
00149             {
00150                 object obj = this.ViewState["EnabledDuringCallBack"];
00151                 if (obj == null)
00152                     return true;
00153                 else
00154                     return (bool)obj;
00155             }
00156             set
00157             {
00158                 ViewState["EnabledDuringCallBack"] = value;
00159             }
00160         }
00161 
00162 
00180         [Category("Anthem")]
00181         [DefaultValue("")]
00182         [Description("The javascript function to call on the client after the callback response is received.")]
00183         public virtual string PostCallBackFunction
00184         {
00185             get
00186             {
00187                 string text = (string)this.ViewState["PostCallBackFunction"];
00188                 if (text == null)
00189                 {
00190                     return string.Empty;
00191                 }
00192                 return text;
00193             }
00194             set
00195             {
00196                 ViewState["PostCallBackFunction"] = value;
00197             }
00198         }
00199 
00205         [Category("Anthem")]
00206         [DefaultValue("")]
00207         [Description("The javascript function to call on the client before the callback is made.")]
00208         public virtual string PreCallBackFunction
00209         {
00210             get
00211             {
00212                 string text = (string)this.ViewState["PreCallBackFunction"];
00213                 if (text == null)
00214                 {
00215                     return string.Empty;
00216                 }
00217                 return text;
00218             }
00219             set
00220             {
00221                 ViewState["PreCallBackFunction"] = value;
00222             }
00223         }
00224 
00233         [Category("Anthem")]
00234         [DefaultValue("")]
00235         [Description("The text to display during the callback.")]
00236         public virtual string TextDuringCallBack
00237         {
00238             get
00239             {
00240                 string text = (string)this.ViewState["TextDuringCallBack"];
00241                 if (text == null)
00242                 {
00243                     return string.Empty;
00244                 }
00245                 return text;
00246             }
00247             set
00248             {
00249                 ViewState["TextDuringCallBack"] = value;
00250             }
00251         }
00252 
00253         #endregion
00254 
00255         #region IUpdatableControl implementation
00256 
00270         [Category("Anthem")]
00271         [DefaultValue(false)]
00272         [Description("True if this control should be updated after each callback.")]
00273         public virtual bool AutoUpdateAfterCallBack
00274         {
00275             get
00276             {
00277                 object obj = this.ViewState["AutoUpdateAfterCallBack"];
00278                 if (obj == null)
00279                     return false;
00280                 else
00281                     return (bool)obj;
00282             }
00283             set
00284             {
00285                 if (value) UpdateAfterCallBack = true;
00286                 ViewState["AutoUpdateAfterCallBack"] = value;
00287             }
00288         }
00289 
00290         private bool _updateAfterCallBack = false;
00291 
00306         [Browsable(false)]
00307         [DefaultValue(false)]
00308         public virtual bool UpdateAfterCallBack
00309         {
00310             get { return _updateAfterCallBack; }
00311             set { _updateAfterCallBack = value; }
00312         }
00313 
00314         #endregion
00315 
00316         #region Common Anthem control code
00317 
00323         protected override void OnLoad(EventArgs e)
00324         {
00325             base.OnLoad(e);
00326             Anthem.Manager.Register(this);
00327         }
00328 
00329 #if V2
00333         public override void RenderControl(HtmlTextWriter writer)
00334         {
00335             base.Visible = true;
00336             base.RenderControl(writer);
00337         }
00338 #endif
00339 
00347         public override bool Visible
00348         {
00349             get
00350             {
00351 #if !V2
00352                 bool DesignMode = this.Context == null;
00353 #endif
00354                 return Anthem.Manager.GetControlVisible(this, ViewState, DesignMode);
00355             }
00356             set { Anthem.Manager.SetControlVisible(ViewState, value); }
00357         }
00358 
00359         #endregion
00360     }
00361 }

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