protected internal override void Render(HtmlTextWriter markupWriter)
        {
            WmlTextWriter writer = (WmlTextWriter)markupWriter;

            string postUrl = Control.PostBackUrl;

            if (!String.IsNullOrEmpty(postUrl))
            {
                postUrl = Control.ResolveClientUrl(Control.PostBackUrl);
            }

            //
            if (Page != null && Page.Request != null && (String)Page.Request.Browser["supportsImageSubmit"] == "false")
            {
                writer.EnterStyle(Control.ControlStyle);

                PageAdapter.RenderPostBackEvent(writer, Control.UniqueID /* target */, "EA" /* argument, placeholder only */, Control.SoftkeyLabel, Control.AlternateText, postUrl, null /* accesskey */);
                writer.ExitStyle(Control.ControlStyle);
                return;
            }
            writer.EnterStyle(Control.ControlStyle);
            ((WmlPageAdapter)PageAdapter).RenderBeginPostBack(writer, Control.SoftkeyLabel /* maps to title attribute, Whidbey 10732 */, Control.AccessKey);
            base.Render(writer);
            ((WmlPageAdapter)PageAdapter).RenderEndPostBack(writer, Control.UniqueID, "EA" /* argument, placeholder only */, postUrl);
            writer.ExitStyle(Control.ControlStyle);
        }
Ejemplo n.º 2
0
        public virtual void Render(WmlTextWriter writer)
        {
            LiteralMode mode = Control.Mode;

            if (mode == LiteralMode.PassThrough || mode == LiteralMode.Encode)
            {
                Style emptyStyle = new Style();
                writer.BeginRender();
                writer.EnterStyle(emptyStyle); // VSWhidbey 114083

                if (mode == LiteralMode.PassThrough)
                {
                    writer.Write(Control.Text);
                }
                else /* mode == LiteralMode.Encode */
                {
                    writer.WriteEncodedText(Control.Text);
                }

                writer.ExitStyle(emptyStyle);
                writer.EndRender();
                return;
            }

            /* mode == LiteralMode.Transform */
            ((WmlPageAdapter)PageAdapter).RenderTransformedText(writer, Control.Text);
        }
Ejemplo n.º 3
0
        protected internal override void Render(HtmlTextWriter markupWriter)
        {
            WmlTextWriter writer = (WmlTextWriter)markupWriter;
            String        source = Control.ImageUrl;
            String        text   = Control.AlternateText;

            writer.EnterStyle(Control.ControlStyle);

            // writer.EnterLayout(Style);

            if (source != null && source.Length == 0)
            {
                // Just write the alternate as text
                writer.WriteEncodedText(text);
            }
            else
            {
                String localSource;

                string symbolProtocol = "symbol:";
                if (StringUtil.StringStartsWith(source, symbolProtocol))
                {
                    localSource = source.Substring(symbolProtocol.Length);
                    source      = String.Empty;
                }
                else
                {
                    localSource = null;
                    // AUI 3652
                    source = Control.ResolveClientUrl(source);
                }
                writer.RenderImage(source, localSource, text);
            }
            writer.ExitStyle(Control.ControlStyle);
        }
Ejemplo n.º 4
0
        protected internal override void Render(HtmlTextWriter markupWriter)
        {
            WmlTextWriter writer = (WmlTextWriter)markupWriter;

            writer.EnterStyle(Control.ControlStyle);
            IItemPaginationInfo itemPaginationInfo = (IItemPaginationInfo)Control;
            int firstIndex = itemPaginationInfo.FirstVisibleItemIndex;

            for (int i = firstIndex; i < firstIndex + itemPaginationInfo.VisibleItemCount; i++)
            {
                RenderBulletText(Control.Items, i, writer);
            }
            writer.ExitStyle(Control.ControlStyle);
        }
Ejemplo n.º 5
0
        protected internal override void Render(HtmlTextWriter markupWriter)
        {
            WmlTextWriter writer = (WmlTextWriter)markupWriter;

            ListItemCollection items = Control.Items;
            int count = items.Count;

            if (count == 0)
            {
                return;
            }

            writer.EnterStyle(Control.ControlStyle);
            bool selected = false;

            if (!Control.Enabled)
            {
                foreach (ListItem item in items)
                {
                    // VSWhidbey 115824
                    if (item.Selected)
                    {
                        if (selected)
                        {
                            Control.VerifyMultiSelect();
                        }
                        selected = true;
                    }
                    RenderDisabledItem(writer, item);
                }
            }
            else
            {
                // Only register post fields if the control is enabled.
                ((WmlPageAdapter)PageAdapter).RegisterPostField(writer, Control);

                if (_ivalue != null)
                {
                    ((WmlPageAdapter)PageAdapter).AddFormVariable(writer, Control.ClientID, _ivalue, false);
                }
                // does not render _ivalue if null or form variables written.
                writer.WriteBeginSelect(null /*name*/,
                                        null /*value*/,
                                        Control.ClientID /*iname*/,
                                        _ivalue /*ivalue*/,
                                        Control.ToolTip /*title*/,
                                        IsMultiSelect);

                foreach (ListItem item in items)
                {
                    // If the item is disabled, don't render it.
                    // WML only allows selectable <options> within <select> elements.
                    if (!item.Enabled)
                    {
                        continue;
                    }

                    // VSWhidbey 115824
                    if (item.Selected)
                    {
                        if (selected && !IsMultiSelect)
                        {
                            throw new HttpException(SR.GetString(SR.Cant_Multiselect_In_Single_Mode));
                        }
                        selected = true;
                    }
                    RenderSelectOption(writer, item);
                }
                writer.WriteEndSelect();
            }

            writer.ExitStyle(Control.ControlStyle);
        }
Ejemplo n.º 6
0
        protected internal override void Render(HtmlTextWriter markupWriter)
        {
            WmlTextWriter writer = (WmlTextWriter)markupWriter;

            String[] errorMessages = null;
            bool     inError       = false;
            bool     enteredStyle  = false;

            if (!Control.Enabled || !Control.Visible || !Control.ShowSummary)
            {
                return;
            }

            errorMessages = Control.GetErrorMessages(out inError);
            if (!inError)
            {
                return;
            }

            if (Control.DisplayMode == ValidationSummaryDisplayMode.SingleParagraph)
            {
                singleParagraph = true;
            }

            if (Control.HeaderText.Length > 0)
            {
                writer.EnterStyle(Control.ControlStyle);
                enteredStyle = true;
                writer.WriteEncodedText(Control.HeaderText);
                WriteSeparator(writer);
            }

            if (!String.IsNullOrEmpty(errorMessages))
            {
                if (!enteredStyle)
                {
                    writer.EnterStyle(Control.ControlStyle);
                    enteredStyle = true;
                }

                if (singleParagraph)
                {
                    foreach (String errorMessage in errorMessages)
                    {
                        Debug.Assert(errorMessage != null && errorMessage.Length > 0, "Bad Error Messages");
                        writer.WriteEncodedText(errorMessage);
                        WriteSeparator(writer);
                    }
                    writer.WriteBreak();
                }
                else
                {
                    ArrayList arr = new ArrayList();
                    foreach (String errorMessage in errorMessages)
                    {
                        Debug.Assert(errorMessage != null && errorMessage.Length > 0, "Bad Error Messages");
                        arr.Add(errorMessage);
                    }

                    bulletedList.DisplayMode = BulletedListDisplayMode.Text;
                    bulletedList.DataSource  = arr;
                    bulletedList.DataBind();

                    RenderChildren(writer);
                }
            }

            if (enteredStyle)
            {
                writer.ExitStyle(Control.ControlStyle);
            }
        }
        //
        protected internal override void Render(HtmlTextWriter markupWriter)
        {
            WmlTextWriter writer = (WmlTextWriter)markupWriter;
            String        text, url, phoneNumber;
            String        controlText = Control.Text;

            // Always strip off optional separators for PhoneNumber before it
            // is added in markup.

            String originalNumber = Control.PhoneNumber;

            char[] plainNumber = new char[originalNumber.Length];  // allocate enough buffer size

            // Loop to strip out optional separators
            int sizeOfPlainNumber = 0;

            for (int i = 0; i < originalNumber.Length; ++i)
            {
                char ch = originalNumber[i];
                if ((ch >= '0' && ch <= '9') || ch == '+')
                {
                    plainNumber[sizeOfPlainNumber] = ch;
                    sizeOfPlainNumber++;
                }
            }

            // Assign the number string with the right size
            phoneNumber = new String(plainNumber, 0, sizeOfPlainNumber);

            // Construct text and url based on device capabilities
            //
            HttpBrowserCapabilities browser = null;

            if (Page != null && Page.Request != null)
            {
                browser = Page.Request.Browser;
            }
            //
            if (browser != null && (String)browser["canInitiateVoiceCall"] != "true")
            {
                text = String.Format(controlText,
                                     originalNumber);
                url = Control.ResolveClientUrl(Control.NavigateUrl);
                url = Control.GetCountClickUrl(url);
            }
            else
            {
                // Some WML browsers require the phone number
                // showing as text so it can be selected.  If it is not
                // formatted in the text yet, append it to the end of the
                // text.
                //
                if (browser != null && browser["requiresPhoneNumbersAsPlainText"] == "true")
                {
                    text = controlText + " " + phoneNumber;
                    url  = String.Empty;
                }
                else
                {
                    text = (!String.IsNullOrEmpty(controlText)) ?
                           controlText : originalNumber;
                    url = "wtai://wp/mc;" + phoneNumber;
                }
            }

            // Write out plain text or corresponding link/softkey command
            // accordingly
            //
            writer.EnterStyle(Control.ControlStyle);
            if (url.Length == 0)
            {
                writer.WriteEncodedText(text);
            }
            else
            {
                String softkeyLabel = Control.SoftkeyLabel;
                if (String.IsNullOrEmpty(softkeyLabel))
                {
                    softkeyLabel = text;
                }
                PageAdapter.RenderBeginHyperlink(writer, url, false /* encode, Whidbey 28731 */, softkeyLabel, Control.AccessKey);
                writer.Write(text);
                PageAdapter.RenderEndHyperlink(writer);
            }
            writer.ExitStyle(Control.ControlStyle);
        }
        //     Transforms text for the target device.  The default transformation is the identity transformation,
        //     which does not change the text.
        internal void RenderTransformedText(WmlTextWriter writer, string text)
        {
            bool leadingSpace  = false;
            bool setPendingP   = false;
            bool trailingSpace = false;

            // p's replaced by brs as in MMIT V1 for valid containment.
            text = LiteralControlAdapterUtility.PreprocessLiteralText(text);
            bool isEmpty = (text != null && text.Length == 0);

            if (isEmpty)
            {
                return;
            }

            if (writer.TopOfForm)
            {
                while (Regex.IsMatch(text, "^(?'space'\\s*)(?:<p|</p)\\s*>"))
                {
                    text = Regex.Replace(text, "^(?'space'\\s*)(?:<p|</p)\\s*>", "${space}", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
                }
            }

            if (setPendingP = Regex.IsMatch(text, "</p\\s*>\\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
            {
                text = Regex.Replace(text, "</p\\s*>(?'space'\\s*)$", "${space}", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
            }

            text = Regex.Replace(text, "<br\\s*/?>", "<br/>", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
            text = Regex.Replace(text, "</p\\s*>(?'space'\\s*)<p\\s*>", "<br/>${space}", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
            text = Regex.Replace(text, "(?:<p|</p)\\s*>", "<br/>", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);

            if (trailingSpace = Regex.IsMatch(text, "\\s+$"))
            {
                text = Regex.Replace(text, "\\s+$", String.Empty);
            }
            if (leadingSpace = Regex.IsMatch(text, "^\\s+"))
            {
                text = Regex.Replace(text, "^\\s+", String.Empty);
            }

            text = text.Replace("$", "$$");

            // Render text.
            if (text.Trim().Length > 0)
            {
                if (leadingSpace)
                {
                    writer.WriteLine();
                }
                Style emptyStyle = new Style();
                writer.BeginRender();          // write pending tags.
                writer.EnterStyle(emptyStyle); // VSWhidbey 114083
                writer.Write(text);
                writer.ExitStyle(emptyStyle);
                writer.EndRender();
                if (trailingSpace)
                {
                    writer.WriteLine();
                }
            }
            // Whidbey 19653 transform space as newline.  If we are at the top of the form (before the leading p),
            // don't need literal text -it won't be rendered. Similarly, if we are setting a pending p, no need to writeline.
            else if (!setPendingP && !writer.TopOfForm)
            {
                Debug.Assert(!isEmpty, "Empty text.  Should have returned before this point.");
                writer.WriteLine();
            }

            if (setPendingP)
            {
                writer.SetPendingP();
            }
        }
Ejemplo n.º 9
0
        protected internal override void Render(HtmlTextWriter markupWriter)
        {
            WmlTextWriter writer    = (WmlTextWriter)markupWriter;
            String        targetUrl = Control.NavigateUrl;

            String text = Control.Text;

            if (text.Length == 0)
            {
                // Whidbey 18195

                foreach (Control child in Control.Controls)
                {
                    if (child is IStaticTextControl)
                    {
                        text = ((IStaticTextControl)child).Text;
                        break;
                    }
                    else if (child is DataBoundLiteralControl)
                    {
                        text = ((DataBoundLiteralControl)child).Text;
                        break;
                    }
                }
            }

            String softkeyLabel = Control.SoftkeyLabel;

            if (softkeyLabel.Length == 0)
            {
                softkeyLabel = Control.Text;
            }
            writer.EnterStyle(Control.ControlStyle);
            // AUI 3652
            targetUrl = Control.ResolveClientUrl(targetUrl);

            targetUrl = Control.GetCountClickUrl(targetUrl);

            // If cookieless mode is on, we need to apply the app path modifier for if the request is authenticated
            HttpContext context = HttpContext.Current;

            Debug.Assert(context != null);
            bool cookieless = CookielessHelperClass.UseCookieless(context, false, FormsAuthentication.CookieMode);

            if (cookieless && context.Request != null && context.Request.IsAuthenticated && context.Response != null)
            {
                targetUrl = context.Response.ApplyAppPathModifier(targetUrl);
            }

            PageAdapter.RenderBeginHyperlink(writer, targetUrl, false /* encode, Whidbey 111129 */, softkeyLabel, Control.AccessKey);
            String source = Control.ImageUrl;

            if (Control.ImageUrl != null && Control.ImageUrl.Length > 0)
            {
                writer.RenderImage(source, null /* localsource */, text /* alternateText */);
            }
            else
            {
                writer.Write(text);
            }
            PageAdapter.RenderEndHyperlink(writer);
            writer.ExitStyle(Control.ControlStyle);
        }
Ejemplo n.º 10
0
        //     Transforms text for the target device.  The default transformation is the identity transformation,
        //     which does not change the text.
        internal void RenderTransformedText(WmlTextWriter writer, string text) {
            bool leadingSpace = false;
            bool setPendingP = false;
            bool trailingSpace = false;

            // p's replaced by brs as in MMIT V1 for valid containment.
            text = LiteralControlAdapterUtility.PreprocessLiteralText(text);
            bool isEmpty = (text != null && text.Length == 0);
            if (isEmpty) {
                return;
            }

            if (writer.TopOfForm) {
                while (Regex.IsMatch(text, "^(?'space'\\s*)(?:<p|</p)\\s*>")) {
                    text = Regex.Replace(text, "^(?'space'\\s*)(?:<p|</p)\\s*>", "${space}", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
                }
            }

            if (setPendingP = Regex.IsMatch(text, "</p\\s*>\\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)) {
                text = Regex.Replace(text, "</p\\s*>(?'space'\\s*)$", "${space}", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
            }

            text = Regex.Replace(text, "<br\\s*/?>", "<br/>", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
            text = Regex.Replace(text, "</p\\s*>(?'space'\\s*)<p\\s*>", "<br/>${space}", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
            text = Regex.Replace(text, "(?:<p|</p)\\s*>", "<br/>", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);

            if (trailingSpace = Regex.IsMatch(text, "\\s+$")) {
                text = Regex.Replace(text, "\\s+$", String.Empty);
            }
            if (leadingSpace = Regex.IsMatch(text, "^\\s+")) {
                text = Regex.Replace(text, "^\\s+", String.Empty);
            }

            text = text.Replace("$", "$$");

            // Render text.
            if (text.Trim().Length > 0) {
                if (leadingSpace) {
                    writer.WriteLine();
                }
                Style emptyStyle = new Style();
                writer.BeginRender(); // write pending tags.
                writer.EnterStyle(emptyStyle); // VSWhidbey 114083
                writer.Write(text);
                writer.ExitStyle(emptyStyle);
                writer.EndRender();
                if (trailingSpace) {
                    writer.WriteLine();
                }
            }
            // Whidbey 19653 transform space as newline.  If we are at the top of the form (before the leading p),
            // don't need literal text -it won't be rendered. Similarly, if we are setting a pending p, no need to writeline.
            else if (!setPendingP && !writer.TopOfForm) {
                Debug.Assert(!isEmpty, "Empty text.  Should have returned before this point.");
                writer.WriteLine();
            }

            if (setPendingP) {
                writer.SetPendingP();
            }
        }