X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Web%2FSystem.Web.UI.WebControls%2FLinkButton.cs;h=1b5e21bf3119b62e04705f5ad0a99d590e7e204b;hb=2d668e958307399970ff9e17e8972ae692413f2b;hp=7cbb45aea82ee458d61451a45b3aaee94cd4ba5a;hpb=4a2ab0336e97f3591eebbb881a1471d3051946c9;p=mono.git diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs b/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs index 7cbb45aea82..1b5e21bf311 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs @@ -60,34 +60,53 @@ namespace System.Web.UI.WebControls { 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); @@ -98,6 +117,11 @@ namespace System.Web.UI.WebControls { OnClick (EventArgs.Empty); OnCommand (new CommandEventArgs (CommandName, CommandArgument)); } + + void IPostBackEventHandler.RaisePostBackEvent (string ea) + { + RaisePostBackEvent (ea); + } protected override void AddParsedSubObject (object obj) { @@ -121,10 +145,25 @@ namespace System.Web.UI.WebControls { } #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 @@ -155,7 +194,7 @@ namespace System.Web.UI.WebControls { #endif override void RenderContents (HtmlTextWriter writer) { - if (HasControls ()) + if (HasControls () || HasRenderMethodDelegate ()) base.RenderContents (writer); else writer.Write (Text); @@ -190,11 +229,8 @@ namespace System.Web.UI.WebControls { [WebCategory ("Behavior")] #if NET_2_0 [Themeable (false)] - public virtual -#else - public #endif - string CommandArgument { + public string CommandArgument { get { return ViewState.GetString ("CommandArgument", ""); } @@ -208,11 +244,8 @@ namespace System.Web.UI.WebControls { [WebCategory ("Behavior")] #if NET_2_0 [Themeable (false)] - public virtual -#else - public #endif - string CommandName { + public string CommandName { get { return ViewState.GetString ("CommandName", ""); } @@ -226,16 +259,15 @@ namespace System.Web.UI.WebControls { #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; } } @@ -296,13 +328,12 @@ namespace System.Web.UI.WebControls { [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; } } @@ -310,7 +341,7 @@ namespace System.Web.UI.WebControls { [Themeable (false)] [WebSysDescription ("")] [WebCategoryAttribute ("Behavior")] - public string ValidationGroup { + public virtual string ValidationGroup { get { return ViewState.GetString ("ValidationGroup", ""); } @@ -322,3 +353,4 @@ namespace System.Web.UI.WebControls { } } +