Ejemplo n.º 1
0
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            if (string.IsNullOrEmpty(AccessKey) && _textWithHotkey.Hotkey.HasValue)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, HotkeyFormatter.FormatHotkey(_textWithHotkey));
            }

            base.AddAttributesToRender(writer);
        }
Ejemplo n.º 2
0
        protected override void RenderContents(HtmlTextWriter writer)
        {
            EvaluateWaiConformity();

            if (IsLegacyButtonEnabled)
            {
                return;
            }

            //For new styles
            //if (ControlHelper.IsDesignMode (this))
            //  return;

            ScriptUtility.Instance.RegisterElementForBorderSpans(this, "#" + ClientID + " > *:first");

            writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClassButtonBody);
            writer.RenderBeginTag(HtmlTextWriterTag.Span);

            var text = HotkeyFormatter.FormatText(_textWithHotkey, false);

            if (HasControls())
            {
                base.RenderContents(writer);
            }
            else
            {
                bool hasIcon = _icon != null && _icon.HasRenderingInformation;
                bool hasText = !string.IsNullOrEmpty(text);
                if (hasIcon)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Src, _icon.Url);
                    if (!_icon.Height.IsEmpty)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Height, _icon.Height.ToString());
                    }
                    if (!_icon.Width.IsEmpty)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Width, _icon.Width.ToString());
                    }
                    writer.AddStyleAttribute("vertical-align", "middle");
                    writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "none");
                    writer.AddAttribute(HtmlTextWriterAttribute.Alt, _icon.AlternateText);
                    writer.RenderBeginTag(HtmlTextWriterTag.Img);
                    writer.RenderEndTag();
                }
                if (hasIcon && hasText)
                {
                    writer.Write(" ");
                }
                if (hasText)
                {
                    writer.Write(text); // Do not HTML enocde
                }
            }

            writer.RenderEndTag(); // End acnhorBody span
        }
Ejemplo n.º 3
0
        protected override void RenderContents(HtmlTextWriter writer)
        {
            if (WcagHelper.Instance.IsWcagDebuggingEnabled() && WcagHelper.Instance.IsWaiConformanceLevelARequired())
            {
                WcagHelper.Instance.HandleError(1, this);
            }

            if (HasControls())
            {
                base.RenderContents(writer);
            }
            else
            {
                writer.Write(HotkeyFormatter.FormatText(_textWithHotkey, false));
            }
        }
Ejemplo n.º 4
0
        protected override Command RenderBeginTagForCommand(WebTabStripRenderingContext renderingContext, IWebTab tab, bool isEnabled, WebTabStyle style)
        {
            ArgumentUtility.CheckNotNull("style", style);

            var menuTab = ((IMenuTab)tab).GetActiveTab();
            var command = GetRenderingCommand(isEnabled, menuTab);

            var additionalUrlParameters = menuTab.GetUrlParameters();
            var backupID        = command.ItemID;
            var backupAccessKey = command.AccessKey;

            try
            {
                if (string.IsNullOrEmpty(command.ItemID) && !string.IsNullOrEmpty(tab.ItemID))
                {
                    command.ItemID = tab.ItemID + "_Command";
                }

                if (string.IsNullOrEmpty(command.AccessKey))
                {
                    var textWithHotkey = HotkeyParser.Parse(tab.Text);
                    if (textWithHotkey.Hotkey.HasValue)
                    {
                        command.AccessKey = HotkeyFormatter.FormatHotkey(textWithHotkey);
                    }
                }

                command.RenderBegin(
                    renderingContext.Writer,
                    RenderingFeatures,
                    tab.GetPostBackClientEvent(),
                    new string[0],
                    string.Empty,
                    null,
                    additionalUrlParameters,
                    false,
                    style);

                return(command);
            }
            finally
            {
                command.ItemID    = backupID;
                command.AccessKey = backupAccessKey;
            }
        }
Ejemplo n.º 5
0
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            if (string.IsNullOrEmpty(AccessKey) && _textWithHotkey.Hotkey.HasValue)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, HotkeyFormatter.FormatHotkey(_textWithHotkey));
            }

            if (IsLegacyButtonEnabled)
            {
                if (!string.IsNullOrEmpty(_textWithHotkey.Text))
                {
                    Text = _textWithHotkey.Text;
                }
                else if (_icon != null && _icon.HasRenderingInformation)
                {
                    Text = _icon.AlternateText;
                }
            }

            if (Page != null)
            {
                Page.VerifyRenderingInServerForm(this);
            }

            if (IsEnabled)
            {
                string onClick = EnsureEndWithSemiColon(OnClientClick);
                if (HasAttributes)
                {
                    string onClickAttribute = Attributes["onclick"];
                    if (onClickAttribute != null)
                    {
                        onClick += EnsureEndWithSemiColon(onClickAttribute);
                        Attributes.Remove("onclick");
                    }
                }

                if (Page != null)
                {
                    var options = GetPostBackOptions();
                    options.ClientSubmit = true;

                    var postBackEventReference = Page.ClientScript.GetPostBackEventReference(options, false);
                    if (string.IsNullOrEmpty(postBackEventReference))
                    {
                        postBackEventReference = Page.ClientScript.GetPostBackEventReference(this, null);
                    }
                    var postBackScript = EnsureEndWithSemiColon(postBackEventReference);

                    onClick += postBackScript;
                    onClick += "return false;";
                }

                if (!string.IsNullOrEmpty(onClick))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onClick);
                }

                writer.AddAttribute("onmousedown", "WebButton_MouseDown (this, '" + CssClassMouseDown + "');");
                writer.AddAttribute("onmouseup", "WebButton_MouseUp (this, '" + CssClassMouseDown + "');");
                writer.AddAttribute("onmouseout", "WebButton_MouseOut (this, '" + CssClassMouseDown + "');");
            }


            _options = base.GetPostBackOptions();
            _options.ClientSubmit      = false;
            _options.PerformValidation = false;
            _options.AutoPostBack      = false;

            string backUpOnClientClick = OnClientClick;

            OnClientClick = null;

            var cssClassBackup       = ControlStyle.CssClass;
            var originalCssClass     = (CssClass ?? "").Replace(DisabledCssClass, "").Trim();
            var isCssStyleOverridden = !string.IsNullOrEmpty(originalCssClass);
            var computedCssClass     = isCssStyleOverridden ? originalCssClass : CssClassBase;

            ControlStyle.CssClass = computedCssClass;

            base.AddAttributesToRender(writer);

            ControlStyle.CssClass = cssClassBackup;

            OnClientClick = backUpOnClientClick;

            // Must be after OnClientClick has been reset
            if (_renderingFeatures.EnableDiagnosticMetadata)
            {
                AddDiagnosticMetadataAttributes(writer);
            }

            _options = null;
        }