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