/// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 internal void WritePostField(String name, String value, WmlPostFieldType type)
 {
     Write("<postfield name=\"");
     Write(name);
     Write("\" value=\"");
     if (type == WmlPostFieldType.Variable)
     {
         Write("$(");
     }
     if (type == WmlPostFieldType.Normal)
     {
         if (Browser["requiresUrlEncodedPostfieldValues"] != "false")
         {
             WriteEncodedUrlParameter(value);
         }
         else
         {
             WriteEncodedText(value);
         }
     }
     else
     {
         Write(value);
     }
     if (type == WmlPostFieldType.Variable)
     {
         Write(")");
     }
     Write("\" />");
 }
示例#2
0
        /// <include file='doc\WmlControlAdapter.uex' path='docs/doc[@for="WmlControlAdapter.RenderPostBackEvent1"]/*' />
        protected void RenderPostBackEvent(
            WmlMobileTextWriter writer,
            String argument,
            String softkeyLabel,
            bool mapToSoftkey,
            String text,
            bool breakAfter,
            WmlPostFieldType postBackType)
        {
            bool implicitSoftkeyLabel = false;

            if (mapToSoftkey)
            {
                if (softkeyLabel == null || softkeyLabel.Length == 0)
                {
                    softkeyLabel         = text;
                    implicitSoftkeyLabel = true;
                }

                if (!writer.IsValidSoftkeyLabel(softkeyLabel))
                {
                    // If softkey label was specified explicitly, then truncate.
                    if (!implicitSoftkeyLabel && softkeyLabel.Length > 0)
                    {
                        softkeyLabel = softkeyLabel.Substring(0, Device.MaximumSoftkeyLabelLength);
                    }
                    else
                    {
                        softkeyLabel         = GetDefaultLabel(GoLabel);
                        implicitSoftkeyLabel = true;
                    }
                }
            }

            writer.RenderBeginPostBack(softkeyLabel, implicitSoftkeyLabel, mapToSoftkey);
            writer.RenderText(text);
            writer.RenderEndPostBack(Control.UniqueID, argument, postBackType, true, breakAfter);
        }
        /// <include file='doc\UpWmlMobileTextWriter.uex' path='docs/doc[@for="UpWmlMobileTextWriter.AnalyzePostBack"]/*' />
        protected override void AnalyzePostBack(bool includeVariables, WmlPostFieldType postBackType)
        {
            base.AnalyzePostBack(includeVariables, postBackType);
            if (CurrentForm.Action.Length > 0)
            {
                if (postBackType == WmlPostFieldType.Submit)
                {
                    _currentCardSubmits++;
                    CurrentCard.ExternalSubmitMenu = true;
                }
                else
                {
                    _currentCardPostBacks++;
                }
                if (_currentCardPostBacks > 0 && _currentCardSubmits > 0)
                {
                    // Posts to more than one target, so we can't use a menu card.

                    CurrentCard.RenderAsMenu  = false;
                    CurrentCard.MenuCandidate = false;
                }
            }
        }
示例#4
0
 public virtual void RenderEndPostBack(string target, string argument, WmlPostFieldType postBackType, bool includeVariables, bool breakAfter)
 {
 }
 public virtual void RenderEndPostBack(string target, string argument, WmlPostFieldType postBackType, bool includeVariables, bool breakAfter)
 {
 }
示例#6
0
 public virtual void RenderGoAction(string target, string argument, WmlPostFieldType postBackType, bool includeVariables)
 {
 }
示例#7
0
 public void WritePostField(string name, string value, WmlPostFieldType type)
 {
 }
        //     Render a complete form post in a go action.  This is used when rendering a postback card, or when
        //     rendering a go action that posts back directly rather than redirecting to a postback card.
        private void RenderFormPostInGoAction(WmlTextWriter writer, string target, string argument, WmlPostFieldType postFieldType, String postUrl) {
            writer.WriteBeginTag("go");
            writer.Write(" href=\"");

            if (!Page.ContainsCrossPagePost) {
                RenderPostBackUrl(writer, Page.RelativeFilePath);
                RenderFormQueryString(writer, QueryString);
            }
            else if (!String.IsNullOrEmpty(postUrl)) {
                RenderPostBackUrl(writer, postUrl);
            }
            else {
                writer.Write("$(");
                writer.Write(_postUrlVarName);
                if (!StringUtil.EqualsIgnoreCase((string)Browser["requiresNoescapedPostUrl"], "false")) {
                    writer.Write(":noescape");
                }
                writer.Write(")");
             }
            writer.Write("\"");

            string method = Page.Form.Method;
            RenderFormMethodAttribute(writer, method);
            writer.Write(">");

            string clientState = ClientState;
            if (clientState != null) {
                ICollection stateChunks = Page.DecomposeViewStateIntoChunks();

                int numChunks = stateChunks.Count;
                if (numChunks > 1) {
                    RenderStatePostField(writer, Page.ViewStateFieldCountID, stateChunks.Count.ToString(CultureInfo.CurrentCulture));
                }

                int count = 0;
                foreach (String state in stateChunks) {
                    string key = Page.ViewStateFieldPrefixID;
                    if (count > 0 ) {
                        key += count.ToString(CultureInfo.CurrentCulture);
                    }
                    RenderStatePostField(writer, key, state);
                    ++count;
                }
            }

            RenderReferrerPagePostField(writer);
            RenderTargetAndArgumentPostFields(writer, target, argument, postFieldType);
            RenderPostFieldVariableDictionary(writer, _dynamicPostFields);
            RenderPostFieldDictionary(writer, _staticPostFields);
            // 
            writer.WriteEndTag("go");
        }
 protected virtual void AnalyzePostBack(WmlPostFieldType postBackType) {
     _numberOfPostBacks++;
 }
        /// <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\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlMobileTextWriter.RenderFormDoEvent"]/*' />
 protected void RenderFormDoEvent(String doType, String arg, WmlPostFieldType postBackType, String text)
 {
     RenderDoEvent(doType, CurrentForm.UniqueID, arg, postBackType, text, true);
 }
        //     Render a complete form post in a go action.  This is used when rendering a postback card, or when
        //     rendering a go action that posts back directly rather than redirecting to a postback card.
        private void RenderFormPostInGoAction(WmlTextWriter writer, string target, string argument, WmlPostFieldType postFieldType, String postUrl)
        {
            writer.WriteBeginTag("go");
            writer.Write(" href=\"");

            if (!Page.ContainsCrossPagePost)
            {
                RenderPostBackUrl(writer, Page.RelativeFilePath);
                RenderFormQueryString(writer, QueryString);
            }
            else if (!String.IsNullOrEmpty(postUrl))
            {
                RenderPostBackUrl(writer, postUrl);
            }
            else
            {
                writer.Write("$(");
                writer.Write(_postUrlVarName);
                if (!StringUtil.EqualsIgnoreCase((string)Browser["requiresNoescapedPostUrl"], "false"))
                {
                    writer.Write(":noescape");
                }
                writer.Write(")");
            }
            writer.Write("\"");

            string method = Page.Form.Method;

            RenderFormMethodAttribute(writer, method);
            writer.Write(">");

            string clientState = ClientState;

            if (clientState != null)
            {
                ICollection stateChunks = Page.DecomposeViewStateIntoChunks();

                int numChunks = stateChunks.Count;
                if (numChunks > 1)
                {
                    RenderStatePostField(writer, Page.ViewStateFieldCountID, stateChunks.Count.ToString(CultureInfo.CurrentCulture));
                }

                int count = 0;
                foreach (String state in stateChunks)
                {
                    string key = Page.ViewStateFieldPrefixID;
                    if (count > 0)
                    {
                        key += count.ToString(CultureInfo.CurrentCulture);
                    }
                    RenderStatePostField(writer, key, state);
                    ++count;
                }
            }

            RenderReferrerPagePostField(writer);
            RenderTargetAndArgumentPostFields(writer, target, argument, postFieldType);
            RenderPostFieldVariableDictionary(writer, _dynamicPostFields);
            RenderPostFieldDictionary(writer, _staticPostFields);
            //
            writer.WriteEndTag("go");
        }
        //     Render postfields for the event target and the event argument.
        private void RenderTargetAndArgumentPostFields(WmlTextWriter writer, string target, string argument, WmlPostFieldType postFieldType)
        {
            // Write the event target.
            if (target != null)
            {
                writer.WritePostField(Page.postEventSourceID, target);
            }
            else
            {
                // Target is null when the action is generated from a postback
                // card itself. In this case, set the event target to whatever
                // the original event target was.
                writer.WritePostFieldVariable(Page.postEventSourceID, _postBackEventTargetVarName);
            }

            // Write the event argument, if valid.

            if (argument != null)
            {
                if (postFieldType == WmlPostFieldType.Variable)
                {
                    writer.WritePostFieldVariable(Page.postEventArgumentID, argument);
                }
                else
                {
                    writer.WritePostField(Page.postEventArgumentID, argument);
                }
            }
        }
 protected virtual void AnalyzePostBack(WmlPostFieldType postBackType)
 {
     _numberOfPostBacks++;
 }
        /// <include file='doc\WmlControlAdapter.uex' path='docs/doc[@for="WmlControlAdapter.RenderPostBackEvent1"]/*' />
        protected void RenderPostBackEvent(
            WmlMobileTextWriter writer,
            String argument,
            String softkeyLabel,
            bool mapToSoftkey,
            String text,
            bool breakAfter,
            WmlPostFieldType postBackType)
        {
            bool implicitSoftkeyLabel = false;
            if (mapToSoftkey)
            {
                if (softkeyLabel == null || softkeyLabel.Length == 0)
                {
                    softkeyLabel = text;
                    implicitSoftkeyLabel = true;
                }

                if (!writer.IsValidSoftkeyLabel(softkeyLabel))
                {
                    // If softkey label was specified explicitly, then truncate.
                    if (!implicitSoftkeyLabel && softkeyLabel.Length > 0)
                    {
                        softkeyLabel = softkeyLabel.Substring(0, Device.MaximumSoftkeyLabelLength);
                    }
                    else
                    {
                        softkeyLabel = GetDefaultLabel(GoLabel);
                        implicitSoftkeyLabel = true;
                    }
                }
            }

            writer.RenderBeginPostBack(softkeyLabel, implicitSoftkeyLabel, mapToSoftkey);
            writer.RenderText(text);
            writer.RenderEndPostBack(Control.UniqueID, argument, postBackType, true, breakAfter);
        }
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 internal void WritePostField(String name, String value, WmlPostFieldType type) {
     Write("<postfield name=\"");
     Write(name);
     Write("\" value=\"");
     if (type == WmlPostFieldType.Variable) {
         Write("$(");
     }
     if (type == WmlPostFieldType.Normal) {
         if (Browser["requiresUrlEncodedPostfieldValues"] != "false") {
             WriteEncodedUrlParameter(value);
         }
         else {
             WriteEncodedText(value);
         }
     }
     else {
         Write(value);
     }
     if (type == WmlPostFieldType.Variable) {
         Write(")");
     }
     Write("\" />");
 }
 public virtual void RenderGoAction(string target, string argument, WmlPostFieldType postBackType, bool includeVariables)
 {
 }
 /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlMobileTextWriter.AnalyzePostBack"]/*' />
 protected virtual void AnalyzePostBack(bool includeVariables, WmlPostFieldType postBackType)
 {
     _usingPostBackType[includeVariables ? 0 : 1] = true;
     if (postBackType != WmlPostFieldType.Submit || CurrentForm.Action.Length == 0)
     {
         _numberOfPostBacks++;
     }
 }
 public void WritePostField(string name, string value, WmlPostFieldType type)
 {
 }
        /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlMobileTextWriter.RenderEndPostBack"]/*' />
        public virtual void RenderEndPostBack(String target, 
                                              String argument, 
                                              WmlPostFieldType postBackType, 
                                              bool includeVariables, 
                                              bool breakAfter)
        {
            if (AnalyzeMode)
            {
                // Analyze postbacks to see if postback cards should
                // be rendered.

                AnalyzePostBack(includeVariables, postBackType);
            }
            else
            {
                RenderGoAction(target, argument, postBackType, includeVariables);
    
                WriteEndTag("anchor");
                if (breakAfter)
                {
                    PendingBreak = true;
                }
                _inAnchor = false;
            }
        }
 /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlMobileTextWriter.RenderDoEvent"]/*' />
 protected void RenderDoEvent(String doType, String target, String arg, WmlPostFieldType postBackType, String text, bool includeVariables)
 {
     //EnsureLayout();
     WriteBeginTag("do");
     WriteAttribute("type", doType);
     if (text != null && text.Length > 0)
     {
         WriteTextEncodedAttribute("label", text);
     }
     Write(">");
     RenderGoAction(target, arg, postBackType, includeVariables);
     WriteEndTag("do");
 }
        //     Render postfields for the event target and the event argument.
        private void RenderTargetAndArgumentPostFields(WmlTextWriter writer, string target, string argument, WmlPostFieldType postFieldType) {
            // Write the event target.
            if (target != null) {
                writer.WritePostField(Page.postEventSourceID, target);
            }
            else {
                // Target is null when the action is generated from a postback
                // card itself. In this case, set the event target to whatever
                // the original event target was.
                writer.WritePostFieldVariable(Page.postEventSourceID, _postBackEventTargetVarName);
            }

            // Write the event argument, if valid.

            if (argument != null) {
                if (postFieldType == WmlPostFieldType.Variable) {
                    writer.WritePostFieldVariable(Page.postEventArgumentID, argument);
                }
                else {
                    writer.WritePostField(Page.postEventArgumentID, argument);
                }
            }
        }
 /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlMobileTextWriter.WritePostField1"]/*' />
 public void WritePostField(String name, String value, WmlPostFieldType type)
 {
     Write("<postfield name=\"");
     Write(name);
     Write("\" value=\"");
     if (type == WmlPostFieldType.Variable)
     {
         Write("$(");
     }
     if (type == WmlPostFieldType.Normal)
     {
         if (Device.RequiresUrlEncodedPostfieldValues)
         {
             WriteEncodedUrlParameter(value);
         }
         else
         {
             WriteEncodedText(value);
         }
     }
     else
     {
         Write(value);
     }
     if (type == WmlPostFieldType.Variable)
     {
         Write(")");
     }
     Write("\" />");
 }
        /// <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\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlMobileTextWriter.RenderGoAction"]/*' />
        public virtual void RenderGoAction(String target, 
                                           String argument, 
                                           WmlPostFieldType postBackType, 
                                           bool includeVariables)
        {

            WriteBeginTag("go");
            Write(" href=\"");

            IDictionary postBackVariables = null;
            if (includeVariables)
            {
                postBackVariables = ((WmlFormAdapter)CurrentForm.Adapter).CalculatePostBackVariables();
                if (postBackVariables == null || postBackVariables.Count == 0)
                {
                    includeVariables = false;
                }
            }

            bool externalSubmit;
            if (postBackType == WmlPostFieldType.Submit)
            {
                externalSubmit = CurrentForm.Action.Length > 0;
                postBackType = WmlPostFieldType.Normal;
            }
            else
            {
                externalSubmit = false;
            }

            if (target != null && !externalSubmit && UsePostBackCard(includeVariables))
            {
                _writtenPostBackType[includeVariables ? 0 : 1] = true;

                // If using postback cards, render a go action to the given
                // postback card, along with setvars setting the target and
                // argument.

                Write("#");
                Write(includeVariables ? _postBackWithVarsCardId : _postBackWithoutVarsCardId);
                Write("\">");
                WriteBeginTag("setvar");
                WriteAttribute("name", _postBackEventTargetVarName);
                WriteAttribute("value", target);
                Write("/>");
                WriteBeginTag("setvar");
                WriteAttribute("name", _postBackEventArgumentVarName);
                Write(" value=\"");
                if (argument != null)
                {
                    if (postBackType == WmlPostFieldType.Variable)
                    {
                        Write("$(");
                        Write(argument);
                        Write(")");
                    }
                    else
                    {
                        WriteEncodedText(argument);
                    }
                }
                Write("\"/>");
            }
            else
            {
                // This is the real postback.

                bool encode = false;
                String url = CalculateFormPostBackUrl(externalSubmit, ref encode);
                FormMethod method = CurrentForm.Method;
                String queryString = CalculateFormQueryString();

                if (encode)
                {
                    WriteEncodedUrl(url);
                }
                else
                {
                    Write(url);
                }

                if(externalSubmit && queryString != null && queryString.Length > 0) 
                {
                    if(Device.RequiresUniqueFilePathSuffix) 
                    {
                        int loc = queryString.IndexOf('&');
                        if(loc != -1) 
                        {
                            queryString = queryString.Substring(0, loc);
                        }
                    }
                    else 
                    {
                        queryString = null;
                    }
                }

                // Add any query string.
                if (queryString != null && queryString.Length > 0)
                {
                    if(externalSubmit && (url.IndexOf('?') != -1))
                    {
                        Write("&amp;");
                    }
                    else 
                    {
                        Write("?");
                    }
                    if (queryString.IndexOf('$') != -1)
                    {
                        queryString = queryString.Replace("$", "$$");
                    }    
                    if(Page.Adapter.PersistCookielessData && Device.CanRenderOneventAndPrevElementsTogether)
                    {
                        queryString = ReplaceFormsCookieWithVariable(queryString);
                    } 
                    base.WriteEncodedText(queryString);
                }
                Write("\"");

                // Method defaults to get in WML, so write it if it's not.
                if (method == FormMethod.Post)
                {
                    WriteAttribute("method", "post");
                }
                Write(">");
    
                // Write the view state as a postfield.
                if (!externalSubmit)
                {
                    String pageState = Page.ClientViewState;
                    if (pageState != null)
                    {
                        if (Device.RequiresSpecialViewStateEncoding)
                        {
                            pageState =
                                ((WmlPageAdapter) Page.Adapter).EncodeSpecialViewState(pageState);
                        }
                        WritePostField(MobilePage.ViewStateID, pageState);
                    }
    
                    // Write the event target.
                    if (target != null)
                    {
                        WritePostField(MobilePage.HiddenPostEventSourceId, target);
                    }
                    else
                    {
                        // Target is null when the action is generated from a postback
                        // card itself. In this case, set the event target to whatever
                        // the original event target was.
    
                        WritePostFieldVariable(MobilePage.HiddenPostEventSourceId, _postBackEventTargetVarName);
                    }

                    // Write the event argument, if valid.
    
                    if (argument != null)
                    {
                        WritePostField(MobilePage.HiddenPostEventArgumentId, argument, postBackType);
                    }
                }
    
                // Write postfields for form variables, if desired. Commands, for example,
                // include form variables. Links do not.

                if (includeVariables)
                {
                    if (postBackVariables != null)
                    {
                        foreach (DictionaryEntry entry in postBackVariables)
                        {
                            Control ctl = (Control)entry.Key;
                            Object value = entry.Value;

                            if (value == null)
                            {
                                // Dynamic value.
                                // Map the client ID to a short name. See
                                // MapClientIDToShortName for details.
                                // Note: Because this is called on the second pass, 
                                // we can just pass false as the second parameter
                                WritePostFieldVariable(ctl.UniqueID, MapClientIDToShortName(ctl.ClientID, false));
                            }
                            else
                            {
                                // Static value.
                                WritePostField(ctl.UniqueID, (String)value);
                            }
                        }
                    }
                }
    
                // Always include page hidden variables.
    
                if (Page.HasHiddenVariables())
                {
                    String hiddenVariablePrefix = MobilePage.HiddenVariablePrefix;
                    foreach (DictionaryEntry entry in Page.HiddenVariables)
                    {
                        if (entry.Value != null)
                        {
                            WritePostField(hiddenVariablePrefix + (String)entry.Key, (String)entry.Value);
                        }
                    }
                }
            }

            WriteEndTag("go");
        }
        /// <include file='doc\UpWmlMobileTextWriter.uex' path='docs/doc[@for="UpWmlMobileTextWriter.AnalyzePostBack"]/*' />
        protected override void AnalyzePostBack(bool includeVariables, WmlPostFieldType postBackType)
        {
            base.AnalyzePostBack(includeVariables, postBackType);
            if (CurrentForm.Action.Length > 0)
            {
                if (postBackType == WmlPostFieldType.Submit)
                {
                    _currentCardSubmits++;
                    CurrentCard.ExternalSubmitMenu = true;
                }
                else
                {
                    _currentCardPostBacks++;
                }
                if (_currentCardPostBacks > 0 && _currentCardSubmits > 0)
                {
                    // Posts to more than one target, so we can't use a menu card.

                    CurrentCard.RenderAsMenu = false;
                    CurrentCard.MenuCandidate = false;
                }
            }
        }