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.LinkButton))]
00013 public class LinkButton : ASP.LinkButton, IUpdatableControl, ICallBackControl
00014 {
00015 #region Unique Anthem control code
00016
00021 protected override void AddAttributesToRender(HtmlTextWriter writer)
00022 {
00023 Anthem.Manager.AddScriptAttribute(
00024 this,
00025 "onclick",
00026 Anthem.Manager.GetCallbackEventReference(
00027 this,
00028 this.CausesValidation,
00029 #if V2
00030 this.ValidationGroup
00031 #else
00032 string.Empty
00033 #endif
00034 ) + "return false;"
00035 );
00036 base.AddAttributesToRender(writer);
00037 }
00038
00039 private const string parentTagName = "span";
00044 protected override void Render(HtmlTextWriter writer)
00045 {
00046 #if !V2
00047 bool DesignMode = this.Context == null;
00048 #endif
00049 if (!DesignMode)
00050 {
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 IUpdatableControl implementation
00238
00252 [Category("Anthem")]
00253 [DefaultValue(false)]
00254 [Description("True if this control should be updated after each callback.")]
00255 public virtual bool AutoUpdateAfterCallBack
00256 {
00257 get
00258 {
00259 object obj = this.ViewState["AutoUpdateAfterCallBack"];
00260 if (obj == null)
00261 return false;
00262 else
00263 return (bool)obj;
00264 }
00265 set
00266 {
00267 if (value) UpdateAfterCallBack = true;
00268 ViewState["AutoUpdateAfterCallBack"] = value;
00269 }
00270 }
00271
00272 private bool _updateAfterCallBack = false;
00273
00288 [Browsable(false)]
00289 [DefaultValue(false)]
00290 public virtual bool UpdateAfterCallBack
00291 {
00292 get { return _updateAfterCallBack; }
00293 set { _updateAfterCallBack = value; }
00294 }
00295
00296 #endregion
00297
00298 #region Common Anthem control code
00299
00305 protected override void OnLoad(EventArgs e)
00306 {
00307 base.OnLoad(e);
00308 Anthem.Manager.Register(this);
00309 }
00310
00311 #if V2
00315 public override void RenderControl(HtmlTextWriter writer)
00316 {
00317 base.Visible = true;
00318 base.RenderControl(writer);
00319 }
00320 #endif
00321
00329 public override bool Visible
00330 {
00331 get
00332 {
00333 #if !V2
00334 bool DesignMode = this.Context == null;
00335 #endif
00336 return Anthem.Manager.GetControlVisible(this, ViewState, DesignMode);
00337 }
00338 set { Anthem.Manager.SetControlVisible(ViewState, value); }
00339 }
00340
00341 #endregion
00342 }
00343 }