/// <summary>
        /// This is exactly the same as in System.Web.UI.WebControls.Button, only the javascript
        /// of the onclick attribute is diferent.
        /// This change was done to support FireFox (#37171)
        /// </summary>
        /// <param name="writer"></param>
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            using (var w = new HtmlTextWriterWithAttributeFilter(writer)) {
                string onClickText = JavaScriptManager.GetButtonOnClickCode(ClientID, UniqueID, ViewStateAttributes.InlineAttributes["onclick"],
                                                                            _confirmMessage, (events != null) && events.Contains(AjaxEventType.onAjaxClick), CausesValidation);

                if (!string.IsNullOrEmpty(_navigateURL))
                {
                    onClickText += "window.location.href='" + _navigateURL + "'; return false;";
                }

                if (onClickText.Length > 0)
                {
                    ViewStateAttributes.InlineAttributes["onclick"] = onClickText;
                }

                bool old_Enabled = Enabled;
                if (!Enabled)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Disabled, ((OSPage)Page).QuirksMode ? null : "disabled");
                    Enabled = true;
                }

                ViewStateAttributes.InlineAttributes.AddAttributes(w);
                base.AddAttributesToRender(w);
                Enabled = old_Enabled;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This is exactly the same as in System.Web.UI.WebControls.LinkButton, only the javascript
        /// of the href attribute is diferent.
        /// This change was done to support FireFox (#37171)
        /// </summary>
        /// <param name="writer"></param>
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            using (var w = new HtmlTextWriterWithAttributeFilter(writer)) {
                if (Page != null)
                {
                    Page.VerifyRenderingInServerForm(this);
                }

                if (ID != null)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
                }

                if (AccessKey.Length > 0)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Accesskey, AccessKey);
                }

                if (!Enabled)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Disabled, ((OSPage)Page).QuirksMode ? null : "disabled");
                }

                if (TabIndex != 0)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Tabindex, TabIndex.ToString());
                }

                if (ToolTip.Length > 0)
                {
                    w.AddAttribute(HtmlTextWriterAttribute.Title, ToolTip);
                }

                if (ControlStyleCreated)
                {
                    ControlStyle.AddAttributesToRender(w, this);
                }

                bool isAjax = (events != null) && events.Contains(AjaxEventType.onAjaxClick);

                string onClickText = JavaScriptManager.GetButtonOnClickCode(ClientID, UniqueID, ViewStateAttributes.InlineAttributes["onclick"],
                                                                            _confirmMessage, isAjax, CausesValidation);

                if (onClickText.Length > 0)
                {
                    ViewStateAttributes.InlineAttributes["onclick"] = onClickText;
                }

                // remove the onclick javascript handler if the control is disabled
                if (!Enabled)
                {
                    ViewStateAttributes.InlineAttributes.Remove("onclick");
                }

                foreach (string attr in Attributes.Keys)
                {
                    w.AddAttribute(attr, Attributes[attr]);
                }

                ViewStateAttributes.InlineAttributes.AddAttributes(w);

                // "#"
                if (Enabled && (Page != null))
                {
                    string htmlTextAttribute = JavaScriptManager.GetLinkHRefCode(ClientID, isAjax, CausesValidation,
                                                                                 Page.ClientScript.GetPostBackEventReference(this, ""), Page.ClientScript.GetPostBackClientHyperlink(this, ""));

                    w.AddAttribute(HtmlTextWriterAttribute.Href, htmlTextAttribute);
                }
            }
        }