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.PlaceHolder))] 00013 public class PlaceHolder : ASP.PlaceHolder, IUpdatableControl, ICallBackContainerControl 00014 { 00015 #region Unique Anthem control code 00016 00017 private const string parentTagName = "span"; 00022 protected override void Render(HtmlTextWriter writer) 00023 { 00024 #if !V2 00025 bool DesignMode = this.Context == null; 00026 #endif 00027 if (EnableCallBack && AddCallBacks) 00028 Anthem.Manager.AddCallBacks(this, 00029 EnabledDuringCallBack, 00030 TextDuringCallBack, 00031 PreCallBackFunction, 00032 PostCallBackFunction, 00033 CallBackCancelledFunction); 00034 00035 if (!DesignMode) 00036 { 00037 Anthem.Manager.WriteBeginControlMarker(writer, parentTagName, this); 00038 } 00039 if (Visible) 00040 { 00041 base.Render(writer); 00042 } 00043 if (!DesignMode) 00044 { 00045 Anthem.Manager.WriteEndControlMarker(writer, parentTagName, this); 00046 } 00047 } 00048 00049 #endregion 00050 00051 #region ICallBackControl implementation 00052 00057 [Category("Anthem")] 00058 [DefaultValue("")] 00059 [Description("The javascript function to call on the client if the callback is cancelled.")] 00060 public virtual string CallBackCancelledFunction 00061 { 00062 get 00063 { 00064 string text = (string)ViewState["CallBackCancelledFunction"]; 00065 if (text == null) 00066 return string.Empty; 00067 else 00068 return text; 00069 } 00070 set 00071 { 00072 ViewState["CallBackCancelledFunction"] = value; 00073 } 00074 } 00075 00083 [Category("Anthem")] 00084 [DefaultValue(true)] 00085 [Description("True if this control uses callbacks instead of postbacks to post data to the server.")] 00086 public virtual bool EnableCallBack 00087 { 00088 get 00089 { 00090 object obj = this.ViewState["EnableCallBack"]; 00091 if (obj == null) 00092 return true; 00093 else 00094 return (bool)obj; 00095 } 00096 set 00097 { 00098 ViewState["EnableCallBack"] = value; 00099 } 00100 } 00101 00110 [Category("Anthem")] 00111 [DefaultValue(true)] 00112 [Description("True if this control is enabled on the client during callbacks.")] 00113 public virtual bool EnabledDuringCallBack 00114 { 00115 get 00116 { 00117 object obj = this.ViewState["EnabledDuringCallBack"]; 00118 if (obj == null) 00119 return true; 00120 else 00121 return (bool)obj; 00122 } 00123 set 00124 { 00125 ViewState["EnabledDuringCallBack"] = value; 00126 } 00127 } 00128 00129 00147 [Category("Anthem")] 00148 [DefaultValue("")] 00149 [Description("The javascript function to call on the client after the callback response is received.")] 00150 public virtual string PostCallBackFunction 00151 { 00152 get 00153 { 00154 string text = (string)this.ViewState["PostCallBackFunction"]; 00155 if (text == null) 00156 { 00157 return string.Empty; 00158 } 00159 return text; 00160 } 00161 set 00162 { 00163 ViewState["PostCallBackFunction"] = value; 00164 } 00165 } 00166 00172 [Category("Anthem")] 00173 [DefaultValue("")] 00174 [Description("The javascript function to call on the client before the callback is made.")] 00175 public virtual string PreCallBackFunction 00176 { 00177 get 00178 { 00179 string text = (string)this.ViewState["PreCallBackFunction"]; 00180 if (text == null) 00181 { 00182 return string.Empty; 00183 } 00184 return text; 00185 } 00186 set 00187 { 00188 ViewState["PreCallBackFunction"] = value; 00189 } 00190 } 00191 00200 [Category("Anthem")] 00201 [DefaultValue("")] 00202 [Description("The text to display during the callback.")] 00203 public virtual string TextDuringCallBack 00204 { 00205 get 00206 { 00207 string text = (string)this.ViewState["TextDuringCallBack"]; 00208 if (text == null) 00209 { 00210 return string.Empty; 00211 } 00212 return text; 00213 } 00214 set 00215 { 00216 ViewState["TextDuringCallBack"] = value; 00217 } 00218 } 00219 00220 #endregion 00221 00222 #region ICallBackContainerControl implementation 00223 00235 [Category("Anthem")] 00236 [DefaultValue(true)] 00237 [Description("True if this control should convert child control postbacks into callbacks.")] 00238 public virtual bool AddCallBacks 00239 { 00240 get 00241 { 00242 object obj = this.ViewState["AddCallBacks"]; 00243 if (obj == null) 00244 return true; 00245 else 00246 return (bool)obj; 00247 } 00248 set 00249 { 00250 ViewState["AddCallBacks"] = value; 00251 } 00252 } 00253 00254 #endregion 00255 00256 #region IUpdatableControl implementation 00257 00271 [Category("Anthem")] 00272 [DefaultValue(false)] 00273 [Description("True if this control should be updated after each callback.")] 00274 public virtual bool AutoUpdateAfterCallBack 00275 { 00276 get 00277 { 00278 object obj = this.ViewState["AutoUpdateAfterCallBack"]; 00279 if (obj == null) 00280 return false; 00281 else 00282 return (bool)obj; 00283 } 00284 set 00285 { 00286 if (value) UpdateAfterCallBack = true; 00287 ViewState["AutoUpdateAfterCallBack"] = value; 00288 } 00289 } 00290 00291 private bool _updateAfterCallBack = false; 00292 00307 [Browsable(false)] 00308 [DefaultValue(false)] 00309 public virtual bool UpdateAfterCallBack 00310 { 00311 get { return _updateAfterCallBack; } 00312 set { _updateAfterCallBack = value; } 00313 } 00314 00315 #endregion 00316 00317 #region Common Anthem control code 00318 00324 protected override void OnLoad(EventArgs e) 00325 { 00326 base.OnLoad(e); 00327 Anthem.Manager.Register(this); 00328 } 00329 00330 #if V2 00334 public override void RenderControl(HtmlTextWriter writer) 00335 { 00336 base.Visible = true; 00337 base.RenderControl(writer); 00338 } 00339 #endif 00340 00348 public override bool Visible 00349 { 00350 get 00351 { 00352 #if !V2 00353 bool DesignMode = this.Context == null; 00354 #endif 00355 return Anthem.Manager.GetControlVisible(this, ViewState, DesignMode); 00356 } 00357 set { Anthem.Manager.SetControlVisible(ViewState, value); } 00358 } 00359 00360 #endregion 00361 } 00362 }