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 (Attributes ["onclick"] != null) {
+ 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) {
+
+ if (enabled && page != null) {
PostBackOptions options = GetPostBackOptions ();
- string href = Page.ClientScript.GetPostBackEventReference (options, true);
+ string href = page.ClientScript.GetPostBackEventReference (options, true);
w.AddAttribute (HtmlTextWriterAttribute.Href, href);
}
base.AddAttributesToRender (w);
+ AddDisplayStyleAttribute (w);
#else
base.AddAttributesToRender (w);
- if (Page == null || !Enabled)
+ 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)));
+ 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
}
#endif
void RaisePostBackEvent (string eventArgument)
{
+#if NET_2_0
+ ValidateEvent (UniqueID, eventArgument);
+#endif
if (CausesValidation)
#if NET_2_0
Page.Validate (ValidationGroup);
protected virtual PostBackOptions GetPostBackOptions ()
{
PostBackOptions options = new PostBackOptions (this);
- options.ActionUrl = (PostBackUrl.Length > 0 ? Page.ResolveClientUrl (PostBackUrl) : null);
+ options.ActionUrl = (PostBackUrl.Length > 0 ?
+#if TARGET_J2EE
+ CreateActionUrl (PostBackUrl)
+#else
+ Page.ResolveClientUrl (PostBackUrl)
+#endif
+ : null);
options.ValidationGroup = null;
- options.Argument = "";
+ options.Argument = String.Empty;
options.ClientSubmit = true;
options.RequiresJavaScriptProtocol = true;
options.PerformValidation = CausesValidation && Page != null && Page.AreValidatorsUplevel (ValidationGroup);
#endif
override void RenderContents (HtmlTextWriter writer)
{
- if (HasControls ())
+ if (HasControls () || HasRenderMethodDelegate ())
base.RenderContents (writer);
else
writer.Write (Text);