private void RenderSoftkey(String doType, UpSoftkey softkey)
        {
            UpHyperlinkSoftkey linkSoftkey = softkey as UpHyperlinkSoftkey;

            if (linkSoftkey != null)
            {
                WriteBeginTag("do");
                WriteAttribute("type", doType);
                WriteTextEncodedAttribute("label", linkSoftkey.Label);
                Write(">");
                WriteBeginTag("go");
                Write(" href=\"");

                if (linkSoftkey.EncodeUrl)
                {
                    WriteEncodedUrl(linkSoftkey.TargetUrl);
                }
                else
                {
                    Write(EscapeAmpersand(linkSoftkey.TargetUrl));
                }
                Write("\" />");
                WriteEndTag("do");
                return;
            }

            UpPostBackSoftkey postBackSoftkey = softkey as UpPostBackSoftkey;

            if (postBackSoftkey != null)
            {
                RenderDoEvent(doType,
                              postBackSoftkey.Target,
                              postBackSoftkey.Argument,
                              postBackSoftkey.PostBackType,
                              postBackSoftkey.Label,
                              postBackSoftkey.IncludeVariables);
                return;
            }
        }
        /// <include file='doc\UpWmlMobileTextWriter.uex' path='docs/doc[@for="UpWmlMobileTextWriter.RenderEndPostBack"]/*' />
        public override void RenderEndPostBack(String target, String argument, WmlPostFieldType postBackType, bool includeVariables, bool breakAfter)
        {
            if (!_inPostBack)
            {
                throw new Exception();
            }

            _inPostBack = false;
            if (AnalyzeMode)
            {
                CheckRawOutput();

                if (CurrentCard.MenuCandidate)
                {
                    // If all postback menu items go to one target, we can write the do
                    // to hit that target. Otherwise, we must post back to the form.

                    if (CurrentCard.RenderAsMenu)
                    {
                        if (CurrentCard.MenuTarget != target)
                        {
                            CurrentCard.MenuTarget = null;
                        }
                    }
                    else
                    {
                        CurrentCard.MenuTarget = target;
                        CurrentCard.RenderAsMenu = true;
                    }
                }
                CurrentCard.HasNonStaticElements = true;

                if (_inSoftkey)
                {
                    // Map to softkey.
                    _inSoftkey = false;
                    UpPostBackSoftkey softkey = new UpPostBackSoftkey();
                    softkey.Target = target;
                    softkey.Argument = argument;
                    softkey.PostBackType = postBackType;
                    softkey.IncludeVariables = includeVariables;
                    if (_softkeyLabel == null || _softkeyLabel.Length == 0)
                    {
                        _softkeyLabel = _linkText;
                    }
                    softkey.Label = _softkeyLabel;
                    CurrentCard.Softkeys[CurrentCard.SoftkeysUsed++] = softkey;
                }
                AnalyzePostBack(includeVariables, postBackType);
            }
            else
            {
                if (CurrentCard.RenderAsMenu)
                {
                    // Render as a menu item.

                    WriteBeginTag("option");
                    if (!_canRenderMixedSelects)
                    {
                        if (_useMenuOptionTitle && IsValidSoftkeyLabel(_softkeyLabel))
                        {
                            WriteTextEncodedAttribute("title", _softkeyLabel);
                        }

                        _requiresOptionSubmitCard = true;
                        Write("><onevent type=\"onpick\"><go href=\"#");
                        Write(_postBackCardPrefix);
                        Write("0");
                        Write(_optionSubmitCardIndex);
                        Write("\">");
                        Write("<setvar name=\"");
                        Write(_postBackEventTargetVarName);
                        Write("\" value=\"");
                        if (_optionMenuName != null)
                        {
                            Write(_optionMenuName);
                        }
                        Write("\" />");
                        Write("<setvar name=\"");
                        Write(_postBackEventArgumentVarName);
                        Write("\" value=\"");
                    }
                    else
                    {
                        Write(" value=\"");
                    }

                    if (CurrentCard.MenuTarget != null)
                    {
                        if (argument != null)
                        {
                            WriteEncodedText(argument);
                        }
                    }
                    else
                    {
                        WriteEncodedText(target);
                        if (argument != null)
                        {
                            Write(",");
                            WriteEncodedText(argument);
                        }
                    }
                    if (!_canRenderMixedSelects)
                    {
                        Write("\" /></go></onevent>");
                    }
                    else
                    {
                        Write("\"");
                        if (_useMenuOptionTitle && IsValidSoftkeyLabel(_softkeyLabel))
                        {
                            WriteTextEncodedAttribute("title", _softkeyLabel);
                        }
                        Write(">");
                    }

                    WriteEncodedText(_linkText);
                    WriteEndTag("option");
                }
                else if (!CurrentCard.UsesDefaultSubmit)
                {
                    base.RenderEndPostBack(target, argument, postBackType, 
                            includeVariables, breakAfter);
                }
            }
            _currentCardAnchorCount++;

            if (!AnalyzeMode &&
                    _currentCardAnchorCount == CurrentCard.AnchorCount && 
                    _currentCardIndex < _cards.Count - 1)
            {
                BeginNextCard();
            }
        }
        /// <include file='doc\UpWmlMobileTextWriter.uex' path='docs/doc[@for="UpWmlMobileTextWriter.RenderEndPostBack"]/*' />
        public override void RenderEndPostBack(String target, String argument, WmlPostFieldType postBackType, bool includeVariables, bool breakAfter)
        {
            if (!_inPostBack)
            {
                throw new Exception();
            }

            _inPostBack = false;
            if (AnalyzeMode)
            {
                CheckRawOutput();

                if (CurrentCard.MenuCandidate)
                {
                    // If all postback menu items go to one target, we can write the do
                    // to hit that target. Otherwise, we must post back to the form.

                    if (CurrentCard.RenderAsMenu)
                    {
                        if (CurrentCard.MenuTarget != target)
                        {
                            CurrentCard.MenuTarget = null;
                        }
                    }
                    else
                    {
                        CurrentCard.MenuTarget   = target;
                        CurrentCard.RenderAsMenu = true;
                    }
                }
                CurrentCard.HasNonStaticElements = true;

                if (_inSoftkey)
                {
                    // Map to softkey.
                    _inSoftkey = false;
                    UpPostBackSoftkey softkey = new UpPostBackSoftkey();
                    softkey.Target           = target;
                    softkey.Argument         = argument;
                    softkey.PostBackType     = postBackType;
                    softkey.IncludeVariables = includeVariables;
                    if (_softkeyLabel == null || _softkeyLabel.Length == 0)
                    {
                        _softkeyLabel = _linkText;
                    }
                    softkey.Label = _softkeyLabel;
                    CurrentCard.Softkeys[CurrentCard.SoftkeysUsed++] = softkey;
                }
                AnalyzePostBack(includeVariables, postBackType);
            }
            else
            {
                if (CurrentCard.RenderAsMenu)
                {
                    // Render as a menu item.

                    WriteBeginTag("option");
                    if (!_canRenderMixedSelects)
                    {
                        if (_useMenuOptionTitle && IsValidSoftkeyLabel(_softkeyLabel))
                        {
                            WriteTextEncodedAttribute("title", _softkeyLabel);
                        }

                        _requiresOptionSubmitCard = true;
                        Write("><onevent type=\"onpick\"><go href=\"#");
                        Write(_postBackCardPrefix);
                        Write("0");
                        Write(_optionSubmitCardIndex);
                        Write("\">");
                        Write("<setvar name=\"");
                        Write(_postBackEventTargetVarName);
                        Write("\" value=\"");
                        if (_optionMenuName != null)
                        {
                            Write(_optionMenuName);
                        }
                        Write("\" />");
                        Write("<setvar name=\"");
                        Write(_postBackEventArgumentVarName);
                        Write("\" value=\"");
                    }
                    else
                    {
                        Write(" value=\"");
                    }

                    if (CurrentCard.MenuTarget != null)
                    {
                        if (argument != null)
                        {
                            WriteEncodedText(argument);
                        }
                    }
                    else
                    {
                        WriteEncodedText(target);
                        if (argument != null)
                        {
                            Write(",");
                            WriteEncodedText(argument);
                        }
                    }
                    if (!_canRenderMixedSelects)
                    {
                        Write("\" /></go></onevent>");
                    }
                    else
                    {
                        Write("\"");
                        if (_useMenuOptionTitle && IsValidSoftkeyLabel(_softkeyLabel))
                        {
                            WriteTextEncodedAttribute("title", _softkeyLabel);
                        }
                        Write(">");
                    }

                    WriteEncodedText(_linkText);
                    WriteEndTag("option");
                }
                else if (!CurrentCard.UsesDefaultSubmit)
                {
                    base.RenderEndPostBack(target, argument, postBackType,
                                           includeVariables, breakAfter);
                }
            }
            _currentCardAnchorCount++;

            if (!AnalyzeMode &&
                _currentCardAnchorCount == CurrentCard.AnchorCount &&
                _currentCardIndex < _cards.Count - 1)
            {
                BeginNextCard();
            }
        }