コード例 #1
0
        public override void RenderBeginHyperlink(HtmlTextWriter writer, string targetUrl, bool encodeUrl, string softkeyLabel, string accessKey)
        {
            WmlTextWriter wmlWriter = (WmlTextWriter)writer;

            if (wmlWriter.AnalyzeMode)
            {
                return;
            }

            // Valid values are null, String.Empty, and single character strings
            if ((accessKey != null) && (accessKey.Length > 1))
            {
                throw new ArgumentOutOfRangeException("accessKey");
            }

            // If the softkey label is too long, let the device choose a default softkey label.
            softkeyLabel = ResolveSoftkeyLabel(softkeyLabel);
            wmlWriter.WriteBeginTag("a");
            wmlWriter.Write(" href=\"");
            if (encodeUrl)
            {
                targetUrl = targetUrl.Replace("$", "$$");
                targetUrl = HttpUtility.HtmlAttributeEncode(targetUrl); // Leaves "$" alone.
                wmlWriter.Write(targetUrl);
            }
            else
            {
                wmlWriter.Write(wmlWriter.EscapeAmpersand(targetUrl));
            }
            wmlWriter.Write("\"");
            if (softkeyLabel != null && softkeyLabel.Length > 0 && !RequiresNoSoftkeyLabels)
            {
                wmlWriter.WriteAttribute("title", softkeyLabel, false /* encode */);
            }
            if (accessKey != null && accessKey.Length > 0 && DoesBrowserSupportAccessKey())
            {
                wmlWriter.WriteAttribute("accessKey", accessKey, false /* encode */);
            }
            wmlWriter.Write(">");
        }