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 {
00017 [ToolboxBitmap(typeof(ASP.DataList))]
00018 public class DataList : ASP.DataList, IUpdatableControl, ICallBackContainerControl
00019 {
00020 #region Unique Anthem control code
00021
00026 protected override void OnCancelCommand(ASP.DataListCommandEventArgs e)
00027 {
00028 base.OnCancelCommand(e);
00029 this.UpdateAfterCallBack = true;
00030 }
00031
00036 protected override void OnDeleteCommand(System.Web.UI.WebControls.DataListCommandEventArgs e)
00037 {
00038 base.OnDeleteCommand(e);
00039 this.UpdateAfterCallBack = true;
00040 }
00041
00046 protected override void OnEditCommand(System.Web.UI.WebControls.DataListCommandEventArgs e)
00047 {
00048 base.OnEditCommand(e);
00049 this.UpdateAfterCallBack = true;
00050 }
00051
00056 protected override void OnItemCommand(System.Web.UI.WebControls.DataListCommandEventArgs e)
00057 {
00058 base.OnItemCommand(e);
00059 this.UpdateAfterCallBack = true;
00060 }
00061
00066 protected override void OnSelectedIndexChanged(EventArgs e)
00067 {
00068 base.OnSelectedIndexChanged(e);
00069 this.UpdateAfterCallBack = true;
00070 }
00071
00076 protected override void OnUpdateCommand(System.Web.UI.WebControls.DataListCommandEventArgs e)
00077 {
00078 base.OnUpdateCommand(e);
00079 this.UpdateAfterCallBack = true;
00080 }
00081
00082 private const string parentTagName = "div";
00087 protected override void Render(HtmlTextWriter writer)
00088 {
00089 #if !V2
00090 bool DesignMode = this.Context == null;
00091 #endif
00092 if (EnableCallBack && AddCallBacks)
00093 Anthem.Manager.AddCallBacks(this,
00094 EnabledDuringCallBack,
00095 TextDuringCallBack,
00096 PreCallBackFunction,
00097 PostCallBackFunction,
00098 CallBackCancelledFunction);
00099
00100 if (!DesignMode)
00101 {
00102 Anthem.Manager.WriteBeginControlMarker(writer, parentTagName, this);
00103 }
00104 if (Visible)
00105 {
00106 base.Render(writer);
00107 }
00108 if (!DesignMode)
00109 {
00110 Anthem.Manager.WriteEndControlMarker(writer, parentTagName, this);
00111 }
00112 }
00113
00114 #endregion
00115
00116 #region ICallBackControl implementation
00117
00122 [Category("Anthem")]
00123 [DefaultValue("")]
00124 [Description("The javascript function to call on the client if the callback is cancelled.")]
00125 public virtual string CallBackCancelledFunction
00126 {
00127 get
00128 {
00129 string text = (string)ViewState["CallBackCancelledFunction"];
00130 if (text == null)
00131 return string.Empty;
00132 else
00133 return text;
00134 }
00135 set
00136 {
00137 ViewState["CallBackCancelledFunction"] = value;
00138 }
00139 }
00140
00148 [Category("Anthem")]
00149 [DefaultValue(true)]
00150 [Description("True if this control uses callbacks instead of postbacks to post data to the server.")]
00151 public virtual bool EnableCallBack
00152 {
00153 get
00154 {
00155 object obj = this.ViewState["EnableCallBack"];
00156 if (obj == null)
00157 return true;
00158 else
00159 return (bool)obj;
00160 }
00161 set
00162 {
00163 ViewState["EnableCallBack"] = value;
00164 }
00165 }
00166
00175 [Category("Anthem")]
00176 [DefaultValue(true)]
00177 [Description("True if this control is enabled on the client during callbacks.")]
00178 public virtual bool EnabledDuringCallBack
00179 {
00180 get
00181 {
00182 object obj = this.ViewState["EnabledDuringCallBack"];
00183 if (obj == null)
00184 return true;
00185 else
00186 return (bool)obj;
00187 }
00188 set
00189 {
00190 ViewState["EnabledDuringCallBack"] = value;
00191 }
00192 }
00193
00211 [Category("Anthem")]
00212 [DefaultValue("")]
00213 [Description("The javascript function to call on the client after the callback response is received.")]
00214 public virtual string PostCallBackFunction
00215 {
00216 get
00217 {
00218 string text = (string)this.ViewState["PostCallBackFunction"];
00219 if (text == null)
00220 {
00221 return string.Empty;
00222 }
00223 return text;
00224 }
00225 set
00226 {
00227 ViewState["PostCallBackFunction"] = value;
00228 }
00229 }
00230
00236 [Category("Anthem")]
00237 [DefaultValue("")]
00238 [Description("The javascript function to call on the client before the callback is made.")]
00239 public virtual string PreCallBackFunction
00240 {
00241 get
00242 {
00243 string text = (string)this.ViewState["PreCallBackFunction"];
00244 if (text == null)
00245 {
00246 return string.Empty;
00247 }
00248 return text;
00249 }
00250 set
00251 {
00252 ViewState["PreCallBackFunction"] = value;
00253 }
00254 }
00255
00264 [Category("Anthem")]
00265 [DefaultValue("")]
00266 [Description("The text to display during the callback.")]
00267 public virtual string TextDuringCallBack
00268 {
00269 get
00270 {
00271 string text = (string)this.ViewState["TextDuringCallBack"];
00272 if (text == null)
00273 {
00274 return string.Empty;
00275 }
00276 return text;
00277 }
00278 set
00279 {
00280 ViewState["TextDuringCallBack"] = value;
00281 }
00282 }
00283
00284 #endregion
00285
00286 #region ICallBackContainerControl implementation
00287
00299 [Category("Anthem")]
00300 [DefaultValue(true)]
00301 [Description("True if this control should convert child control postbacks into callbacks.")]
00302 public virtual bool AddCallBacks
00303 {
00304 get
00305 {
00306 object obj = this.ViewState["AddCallBacks"];
00307 if (obj == null)
00308 return true;
00309 else
00310 return (bool)obj;
00311 }
00312 set
00313 {
00314 ViewState["AddCallBacks"] = value;
00315 }
00316 }
00317
00318 #endregion
00319
00320 #region IUpdatableControl implementation
00321
00335 [Category("Anthem")]
00336 [DefaultValue(false)]
00337 [Description("True if this control should be updated after each callback.")]
00338 public virtual bool AutoUpdateAfterCallBack
00339 {
00340 get
00341 {
00342 object obj = this.ViewState["AutoUpdateAfterCallBack"];
00343 if (obj == null)
00344 return false;
00345 else
00346 return (bool)obj;
00347 }
00348 set
00349 {
00350 if (value) UpdateAfterCallBack = true;
00351 ViewState["AutoUpdateAfterCallBack"] = value;
00352 }
00353 }
00354
00355 private bool _updateAfterCallBack = false;
00356
00371 [Browsable(false)]
00372 [DefaultValue(false)]
00373 public virtual bool UpdateAfterCallBack
00374 {
00375 get { return _updateAfterCallBack; }
00376 set { _updateAfterCallBack = value; }
00377 }
00378
00379 #endregion
00380
00381 #region Common Anthem control code
00382
00387 protected override void OnLoad(EventArgs e)
00388 {
00389 base.OnLoad(e);
00390 Anthem.Manager.Register(this);
00391 }
00392
00393 #if V2
00399 public override void RenderControl(HtmlTextWriter writer)
00400 {
00401 base.Visible = true;
00402 base.RenderControl(writer);
00403 }
00404 #endif
00405
00413 public override bool Visible
00414 {
00415 get
00416 {
00417 #if !V2
00418 bool DesignMode = this.Context == null;
00419 #endif
00420 return Anthem.Manager.GetControlVisible(this, ViewState, DesignMode);
00421 }
00422 set { Anthem.Manager.SetControlVisible(ViewState, value); }
00423 }
00424
00425 #endregion
00426 }
00427 }