protected override void AddAttributesToRender (HtmlTextWriter w)
{
- if (Page != null)
- Page.VerifyRenderingInServerForm (this);
+ Page page = Page;
+ if (page != null)
+ page.VerifyRenderingInServerForm (this);
+ bool enabled = IsEnabled;
+#if NET_2_0
+ string onclick = OnClientClick;
+ onclick = ClientScriptManager.EnsureEndsWithSemicolon (onclick);
+ if (HasAttributes && Attributes ["onclick"] != null) {
+ onclick = ClientScriptManager.EnsureEndsWithSemicolon (onclick + Attributes ["onclick"]);
+ Attributes.Remove ("onclick");
+ }
+
+ if (onclick.Length > 0)
+ w.AddAttribute (HtmlTextWriterAttribute.Onclick, onclick);
+
+ if (enabled && page != null) {
+ PostBackOptions options = GetPostBackOptions ();
+ string href = page.ClientScript.GetPostBackEventReference (options, true);
+ w.AddAttribute (HtmlTextWriterAttribute.Href, href);
+ }
+ base.AddAttributesToRender (w);
+ AddDisplayStyleAttribute (w);
+#else
base.AddAttributesToRender (w);
- if (Page == null)
+ if (page == null || !enabled)
return;
- if (CausesValidation && Page.AreValidatorsUplevel ()) {
- ClientScriptManager csm = new ClientScriptManager (Page);
+ if (CausesValidation && page.AreValidatorsUplevel ()) {
+ ClientScriptManager csm = new ClientScriptManager (page);
w.AddAttribute (HtmlTextWriterAttribute.Href,
- String.Format ("javascript:{{if (typeof(Page_ClientValidate) != 'function' || Page_ClientValidate()) {0};}}",
- csm.GetPostBackEventReference (this, String.Empty)));
- w.AddAttribute ("language", "javascript");
+ String.Concat ("javascript:{if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); ",
+ csm.GetPostBackEventReference (this, String.Empty), ";}"));
} else {
- w.AddAttribute (HtmlTextWriterAttribute.Href, Page.ClientScript.GetPostBackClientHyperlink (this, ""));
+ w.AddAttribute (HtmlTextWriterAttribute.Href, page.ClientScript.GetPostBackClientHyperlink (this, String.Empty));
}
+#endif
}
#if NET_2_0
- [MonoTODO]
- protected virtual void RaisePostBackEvent (string eventArgument)
- {
- throw new NotImplementedException ();
- }
+ protected virtual
#endif
-
- void IPostBackEventHandler.RaisePostBackEvent (string ea)
+ void RaisePostBackEvent (string eventArgument)
{
+#if NET_2_0
+ ValidateEvent (UniqueID, eventArgument);
+#endif
if (CausesValidation)
#if NET_2_0
Page.Validate (ValidationGroup);
OnClick (EventArgs.Empty);
OnCommand (new CommandEventArgs (CommandName, CommandArgument));
}
+
+ void IPostBackEventHandler.RaisePostBackEvent (string ea)
+ {
+ RaisePostBackEvent (ea);
+ }
protected override void AddParsedSubObject (object obj)
{
}
#if NET_2_0
- [MonoTODO]
protected virtual PostBackOptions GetPostBackOptions ()
{
- throw new NotImplementedException ();
+ PostBackOptions options = new PostBackOptions (this);
+ options.ActionUrl = (PostBackUrl.Length > 0 ?
+#if TARGET_J2EE
+ CreateActionUrl (PostBackUrl)
+#else
+ Page.ResolveClientUrl (PostBackUrl)
+#endif
+ : null);
+ options.ValidationGroup = null;
+ options.Argument = String.Empty;
+ options.ClientSubmit = true;
+ options.RequiresJavaScriptProtocol = true;
+ options.PerformValidation = CausesValidation && Page != null && Page.AreValidatorsUplevel (ValidationGroup);
+ if (options.PerformValidation)
+ options.ValidationGroup = ValidationGroup;
+
+ return options;
}
#endif
#endif
override void RenderContents (HtmlTextWriter writer)
{
- if (HasControls ())
+ if (HasControls () || HasRenderMethodDelegate ())
base.RenderContents (writer);
else
writer.Write (Text);
[WebCategory ("Behavior")]
#if NET_2_0
[Themeable (false)]
- public virtual
-#else
- public
#endif
- string CommandArgument {
+ public string CommandArgument {
get {
return ViewState.GetString ("CommandArgument", "");
}
[WebCategory ("Behavior")]
#if NET_2_0
[Themeable (false)]
- public virtual
-#else
- public
#endif
- string CommandName {
+ public string CommandName {
get {
return ViewState.GetString ("CommandName", "");
}
#if NET_2_0
[DefaultValue ("")]
[Themeable (false)]
- [MonoTODO]
[WebSysDescription ("")]
[WebCategoryAttribute ("Behavior")]
public virtual string OnClientClick
{
get {
- throw new NotImplementedException ();
+ return ViewState.GetString ("OnClientClick", "");
}
set {
- throw new NotImplementedException ();
+ ViewState ["OnClientClick"] = value;
}
}
[Themeable (false)]
[UrlProperty ("*.aspx")]
[DefaultValue ("")]
- [MonoTODO]
- public string PostBackUrl {
+ public virtual string PostBackUrl {
get {
- throw new NotImplementedException ();
+ return ViewState.GetString ("PostBackUrl", String.Empty);
}
set {
- throw new NotImplementedException ();
+ ViewState["PostBackUrl"] = value;
}
}
[Themeable (false)]
[WebSysDescription ("")]
[WebCategoryAttribute ("Behavior")]
- public string ValidationGroup {
+ public virtual string ValidationGroup {
get {
return ViewState.GetString ("ValidationGroup", "");
}
}
}
+