public virtual void RenderSelectOptionAsPostBack(WmlTextWriter writer, string text, String target, String argument)
        {
            if (writer.AnalyzeMode)
            {
                return;
            }

            writer.WriteFullBeginTag("option");
            writer.WriteBeginTag("onevent");
            writer.WriteAttribute("type", "onpick");
            writer.Write(">");
            writer.WriteBeginTag("go");
            writer.WriteAttribute("href", "#" + WmlTextWriter.PostBackWithVarsCardID);
            writer.Write(">");
            if (!String.IsNullOrEmpty(target))
            {
                writer.WriteBeginTag("setvar");
                writer.WriteAttribute("name", _postBackEventTargetVarName);
                writer.WriteAttribute("value", target);
                writer.Write(" />");
            }
            if (!String.IsNullOrEmpty(argument))
            {
                writer.WriteBeginTag("setvar");
                writer.WriteAttribute("name", _postBackEventArgumentVarName);
                writer.WriteAttribute("value", argument);
                writer.Write(" />");
            }
            writer.WriteEndTag("go");
            writer.WriteEndTag("onevent");
            writer.WriteEncodedText(text);
            writer.WriteEndTag("option");
            _writtenPostBack  = true;
            _usePostBackCards = true;
        }
        // Renders the beginning of the form.
        //
        protected internal virtual void RenderBeginForm(WmlTextWriter writer)
        {
            RenderBeginCardTag(writer);

            // Write form variables.

            //


            _writtenFormVariables = true;
            if (_formVariables == null)
            {
                _formVariables = new ListDictionary();
            }
            _formVariables[_postBackEventTargetVarName]   = String.Empty; // Whidbey 18260
            _formVariables[_postBackEventArgumentVarName] = String.Empty;
            writer.Write("<onevent type=\"onenterforward\"><refresh>");
            RenderSetFormVariables(writer);
            RenderPostUrlFormVariable(writer);
            writer.WriteLine("</refresh></onevent>");
            writer.Write("<onevent type=\"onenterbackward\"><refresh>");
            RenderSetFormVariables(writer);
            RenderPostUrlFormVariable(writer);
            writer.WriteLine("</refresh></onevent>");
            //
            writer.BeginFormOrPanel();
        }
Ejemplo n.º 3
0
        // Renders the beginning of the form.
        // UNDONE: Remove internal modifier when method is completely removed from writer.
        protected internal virtual void RenderBeginForm(WmlTextWriter writer)
        {
            RenderBeginCardTag(writer);

            // Write form variables.

            // UNDONE: Move writer._provideBackButton to this adapter.
            // Review: In V1 we had a writer.ProvideBackButton property, is there any need for this with (more advanced)
            // whidbey devices?
            _writtenFormVariables = true;
            if (_formVariables == null)
            {
                _formVariables = new ListDictionary();
            }
            _formVariables[_postBackEventTargetVarName]   = String.Empty; // Whidbey 18260
            _formVariables[_postBackEventArgumentVarName] = String.Empty;
            writer.Write("<onevent type=\"onenterforward\"><refresh>");
            RenderSetFormVariables(writer);
            RenderPostUrlFormVariable(writer);
            writer.WriteLine("</refresh></onevent>");
            writer.Write("<onevent type=\"onenterbackward\"><refresh>");
            RenderSetFormVariables(writer);
            RenderPostUrlFormVariable(writer);
            writer.WriteLine("</refresh></onevent>");
            // UNDONE: formAdapter.RenderExtraCardElements(this);
            writer.BeginFormOrPanel();
        }
        private void RenderGoActionToPostbackCard(WmlTextWriter writer, String target, String argument, String postUrl)
        {
            // If using postback cards, render a go action to the given
            // postback card, along with setvars setting the target and
            // argument.
            writer.WriteBeginTag("go");
            writer.Write(" href=\"");
            _writtenPostBack = true;
            writer.Write("#");
            writer.Write(WmlTextWriter.PostBackWithVarsCardID);
            writer.Write("\">");
            writer.WriteBeginTag("setvar");
            writer.WriteAttribute("name", _postBackEventTargetVarName);
            writer.WriteAttribute("value", target);
            writer.Write("/>");
            writer.WriteBeginTag("setvar");
            writer.WriteAttribute("name", _postBackEventArgumentVarName);
            writer.Write(" value=\"");
            if (argument != null)
            {
                writer.WriteEncodedText(argument);
            }
            writer.Write("\"/>");

            if (!String.IsNullOrEmpty(postUrl))
            {
                writer.WriteBeginTag("setvar");
                writer.WriteAttribute("name", _postUrlVarName);
                writer.Write(" value=\"");
                writer.WriteEncodedUrl(postUrl);
                writer.Write("\"/>");
            }

            writer.WriteEndTag("go");
        }
 private void RenderPostUrlFormVariable(WmlTextWriter writer)
 {
     if (Page.ContainsCrossPagePost)
     {
         writer.WriteBeginTag("setvar");
         writer.WriteAttribute("name", _postUrlVarName);
         writer.Write(" value=\"");
         RenderPostBackUrl(writer, Page.RelativeFilePath);
         RenderFormQueryString(writer, QueryString);
         writer.Write("\" />");
     }
 }
        private void RenderXmlHeader(WmlTextWriter writer)
        {
            writer.Write(_headerBegin);
            String charset = Page.Response.Charset;

            if (charset != null && charset.Length > 0 &&
                !StringUtil.EqualsIgnoreCase(charset, "utf-8"))
            {
                writer.Write(String.Format(_headerEncoding, charset));
            }
            writer.Write(_headerEnd);
        }
Ejemplo n.º 7
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);
        }
 private void RenderSetFormVariables(WmlTextWriter writer)
 {
     foreach (DictionaryEntry entry in _formVariables)
     {
         writer.WriteBeginTag("setvar");
         writer.WriteAttribute("name", (String)entry.Key);
         writer.WriteAttribute("value", (String)entry.Value, true);
         writer.Write(" />");
     }
 }
 //     Renders the cache expiry as a header or meta element.
 private void RenderCacheExpiry(WmlTextWriter writer)
 {
     if (!StringUtil.EqualsIgnoreCase(Browser["SupportsCacheControlMetaTag"], "false"))
     {
         writer.Write(_cacheExpiry);
     }
     else
     {
         Page.Response.AppendHeader("Cache-Control", "max-age=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(">");
        }
        public virtual void RenderSelectOption(WmlTextWriter writer, String text, String value)
        {
            if (writer.AnalyzeMode)
            {
                return;
            }

            writer.WriteBeginTag("option");
            writer.WriteAttribute("value", value, true);
            writer.Write(">");
            writer.WriteEncodedText(text);
            writer.WriteEndTag("option");
        }
        public virtual void RenderSelectOptionWithNavigateUrl(WmlTextWriter writer, String text, string navigateUrl)
        {
            if (writer.AnalyzeMode)
            {
                return;
            }

            writer.WriteBeginTag("option");
            writer.WriteAttribute("onpick", navigateUrl);
            writer.Write(">");
            writer.WriteEncodedText(text);
            writer.WriteEndTag("option");
        }
        //     Renders the Form query string.
        private void RenderFormQueryString(WmlTextWriter writer, string queryString)
        {
            if (String.IsNullOrEmpty(queryString))
            {
                return;
            }
            writer.Write("?");
            //

            if (!StringUtil.EqualsIgnoreCase((string)Browser["canRenderOneventAndPrevElementsTogether"], "false"))
            {
                queryString = writer.ReplaceFormsCookieWithVariable(queryString);
            }
            writer.WriteEncodedText(queryString);
        }
 public void RenderSelectOptionAsAutoPostBack(WmlTextWriter writer, string text, string groupName, string value)
 {
     if (writer.AnalyzeMode)
     {
         return;
     }
     writer.WriteFullBeginTag("option");
     writer.WriteBeginTag("onevent");
     writer.WriteAttribute("type", "onpick");
     writer.Write(">");
     writer.WriteBeginTag("go");
     writer.WriteAttribute("href", "#" + WmlTextWriter.PostBackWithVarsCardID);
     writer.Write(">");
     writer.WriteBeginTag("setvar");
     writer.WriteAttribute("name", writer.MapClientIDToShortName(groupName, false));
     writer.WriteAttribute("value", value);
     writer.Write(" />");
     writer.WriteEndTag("go");
     writer.WriteEndTag("onevent");
     writer.WriteEncodedText(text);
     writer.WriteEndTag("option");
     _writtenPostBack  = true;
     _usePostBackCards = true;
 }
Ejemplo n.º 15
0
 //     Renders the Form query string.
 private void RenderFormQueryString(WmlTextWriter writer, string queryString)
 {
     if (String.IsNullOrEmpty(queryString))
     {
         return;
     }
     writer.Write("?");
     // UNDONE: MMIT IPageAdapter.PersistCookielessData NYI
     // if(Page.Adapter.PersistCookielessData && Browser["canRenderOneventAndPrevElementsTogether"] != "false")
     if (!StringUtil.EqualsIgnoreCase((string)Browser["canRenderOneventAndPrevElementsTogether"], "false"))
     {
         queryString = writer.ReplaceFormsCookieWithVariable(queryString);
     }
     writer.WriteEncodedText(queryString);
 }
        //     Renders postback cards.
        private void RenderPostBackCard(WmlTextWriter writer)
        {
            if (!_writtenPostBack)
            {
                return;
            }

            writer.WriteBeginTag("card");
            writer.WriteAttribute("id", WmlTextWriter.PostBackWithVarsCardID);
            writer.WriteLine(">");

            writer.Write("<onevent type=\"onenterforward\">");
            RenderFormPostInGoAction(writer, null, _postBackEventArgumentVarName, WmlPostFieldType.Variable, String.Empty);
            //
            writer.WriteLine("</onevent>");

            writer.WriteLine("<onevent type=\"onenterbackward\"><prev /></onevent>");
            writer.WriteLine("</card>");
        }
        public virtual void RenderBeginPostBack(WmlTextWriter writer, string softkeyLabel, string accessKey)
        {
            if (writer.AnalyzeMode)
            {
                return;
            }

            // If the softkey label is too long, let the device choose a default softkey label.
            softkeyLabel = ResolveSoftkeyLabel(softkeyLabel);
            writer.WriteBeginTag("anchor");
            if (softkeyLabel != null && softkeyLabel.Length > 0 && !RequiresNoSoftkeyLabels)
            {
                writer.WriteAttribute("title", softkeyLabel, false /* encode Whidbey 17925 */);
            }
            if (accessKey != null && accessKey.Length > 0 && DoesBrowserSupportAccessKey())
            {
                writer.WriteAttribute("accessKey", accessKey);
            }
            writer.Write(">");
        }
        public void RenderSelectOptionAsAutoPostBack(WmlTextWriter writer, string text, string value)
        {
            if (writer.AnalyzeMode)
            {
                return;
            }

            writer.WriteBeginTag("option");
            if (!String.IsNullOrEmpty(value))
            {
                writer.WriteAttribute("value", value, true);
            }
            writer.WriteAttribute("onpick", "#" + WmlTextWriter.PostBackWithVarsCardID);
            writer.Write(">");
            writer.WriteEncodedText(text);
            writer.WriteEndTag("option");
            // force use of postback cards with variables.
            _writtenPostBack  = true;
            _usePostBackCards = true;
        }
        public override void RenderPostBackEvent(HtmlTextWriter writer, string target, string argument, string softkeyLabel, string text, string postUrl, string accessKey)
        {
            WmlTextWriter wmlWriter = writer as WmlTextWriter;

            if (wmlWriter == null)
            {
                base.RenderPostBackEvent(writer, target, argument, softkeyLabel, text, postUrl, accessKey);
                return;
            }
            if (String.IsNullOrEmpty(softkeyLabel))
            {
                softkeyLabel = text;
            }

            if (!String.IsNullOrEmpty(postUrl))
            {
                Page.ContainsCrossPagePost = true;
            }

            RenderBeginPostBack((WmlTextWriter)writer, softkeyLabel, accessKey);
            wmlWriter.Write(text);
            RenderEndPostBack((WmlTextWriter)writer, target, argument, postUrl);
        }
Ejemplo n.º 20
0
        //     Renders postback cards.
        private void RenderPostBackCard(WmlTextWriter writer) {
            if (!_writtenPostBack) {
                return;
            }

            writer.WriteBeginTag("card");
            writer.WriteAttribute("id", WmlTextWriter.PostBackWithVarsCardID);
            writer.WriteLine(">");

            writer.Write("<onevent type=\"onenterforward\">");
            RenderFormPostInGoAction(writer, null, _postBackEventArgumentVarName, WmlPostFieldType.Variable, String.Empty);
            // 
            writer.WriteLine("</onevent>");

            writer.WriteLine("<onevent type=\"onenterbackward\"><prev /></onevent>");
            writer.WriteLine("</card>");
        }
Ejemplo n.º 21
0
        public virtual void RenderSelectOption(WmlTextWriter writer, String text, String value) {
            if (writer.AnalyzeMode) {
                return;
            }

            writer.WriteBeginTag("option");
            writer.WriteAttribute("value", value, true);
            writer.Write(">");
            writer.WriteEncodedText(text);
            writer.WriteEndTag("option");
        }
Ejemplo n.º 22
0
        public virtual void RenderSelectOptionWithNavigateUrl(WmlTextWriter writer, String text, string navigateUrl) {
            if (writer.AnalyzeMode) {
                return;
            }

            writer.WriteBeginTag("option");
            writer.WriteAttribute("onpick", navigateUrl);
            writer.Write(">");
            writer.WriteEncodedText(text);
            writer.WriteEndTag("option");
        }
Ejemplo n.º 23
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();
            }
        }
        //     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.º 25
0
        //     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");
        }
Ejemplo n.º 26
0
 public void RenderSelectOptionAsAutoPostBack(WmlTextWriter writer, string text, string groupName, string value) {
     if (writer.AnalyzeMode) {
         return;
     }
     writer.WriteFullBeginTag("option");
     writer.WriteBeginTag("onevent");
     writer.WriteAttribute("type", "onpick");
     writer.Write(">");
     writer.WriteBeginTag("go");
     writer.WriteAttribute("href", "#" + WmlTextWriter.PostBackWithVarsCardID);
     writer.Write(">");
     writer.WriteBeginTag("setvar");
     writer.WriteAttribute("name", writer.MapClientIDToShortName(groupName, false));
     writer.WriteAttribute("value", value);
     writer.Write(" />");
     writer.WriteEndTag("go");
     writer.WriteEndTag("onevent");
     writer.WriteEncodedText(text);
     writer.WriteEndTag("option");
     _writtenPostBack = true;
     _usePostBackCards = true;
 }
Ejemplo n.º 27
0
 private void RenderPostUrlFormVariable(WmlTextWriter writer) {
     if (Page.ContainsCrossPagePost) {
         writer.WriteBeginTag("setvar");
         writer.WriteAttribute("name", _postUrlVarName);
         writer.Write(" value=\"");
         RenderPostBackUrl(writer, Page.RelativeFilePath);
         RenderFormQueryString(writer, QueryString);
         writer.Write("\" />");
     }
 }
        //
        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);
        }
Ejemplo n.º 29
0
        public virtual void RenderBeginPostBack(WmlTextWriter writer, string softkeyLabel, string accessKey) {
            if (writer.AnalyzeMode) {
                return;
            }

            // If the softkey label is too long, let the device choose a default softkey label.
            softkeyLabel = ResolveSoftkeyLabel(softkeyLabel);
            writer.WriteBeginTag("anchor");
            if (softkeyLabel != null && softkeyLabel.Length > 0 && !RequiresNoSoftkeyLabels)
                writer.WriteAttribute("title", softkeyLabel, false /* encode Whidbey 17925 */);
            if (accessKey != null && accessKey.Length > 0 && DoesBrowserSupportAccessKey())
                writer.WriteAttribute("accessKey", accessKey);
            writer.Write(">");
        }
Ejemplo n.º 30
0
        public void RenderSelectOptionAsAutoPostBack(WmlTextWriter writer, string text, string value) {
            if (writer.AnalyzeMode) {
                return;
            }

            writer.WriteBeginTag("option");
            if (!String.IsNullOrEmpty(value)) {
                writer.WriteAttribute("value", value, true);
            }
            writer.WriteAttribute("onpick", "#" + WmlTextWriter.PostBackWithVarsCardID);
            writer.Write(">");
            writer.WriteEncodedText(text);
            writer.WriteEndTag("option");
            // force use of postback cards with variables.
            _writtenPostBack = true;
            _usePostBackCards = true;
        }
Ejemplo n.º 31
0
 private void RenderXmlHeader(WmlTextWriter writer) {
     writer.Write(_headerBegin);
     String charset = Page.Response.Charset;
     if (charset != null && charset.Length > 0 &&
         !StringUtil.EqualsIgnoreCase(charset, "utf-8")) {
         writer.Write(String.Format(_headerEncoding, charset));
     }
     writer.Write(_headerEnd);
 }
Ejemplo n.º 32
0
 //     Renders the Form query string.
 private void RenderFormQueryString(WmlTextWriter writer, string queryString) {
     if (String.IsNullOrEmpty(queryString)) {
         return;
     }
     writer.Write("?");
     // UNDONE: MMIT IPageAdapter.PersistCookielessData NYI
     // if(Page.Adapter.PersistCookielessData && Browser["canRenderOneventAndPrevElementsTogether"] != "false")
     if (!StringUtil.EqualsIgnoreCase((string)Browser["canRenderOneventAndPrevElementsTogether"], "false")) {
         queryString = writer.ReplaceFormsCookieWithVariable(queryString);
     }
     writer.WriteEncodedText(queryString);
 }
        //     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");
        }
Ejemplo n.º 34
0
        private void RenderGoActionToPostbackCard(WmlTextWriter writer, String target, String argument, String postUrl) {
            // If using postback cards, render a go action to the given
            // postback card, along with setvars setting the target and
            // argument.
            writer.WriteBeginTag("go");
            writer.Write(" href=\"");
            _writtenPostBack = true;
            writer.Write("#");
            writer.Write(WmlTextWriter.PostBackWithVarsCardID);
            writer.Write("\">");
            writer.WriteBeginTag("setvar");
            writer.WriteAttribute("name", _postBackEventTargetVarName);
            writer.WriteAttribute("value", target);
            writer.Write("/>");
            writer.WriteBeginTag("setvar");
            writer.WriteAttribute("name", _postBackEventArgumentVarName);
            writer.Write(" value=\"");
            if (argument != null) {
                writer.WriteEncodedText(argument);
            }
            writer.Write("\"/>");

            if (!String.IsNullOrEmpty(postUrl)) {
                writer.WriteBeginTag("setvar");
                writer.WriteAttribute("name", _postUrlVarName);
                writer.Write(" value=\"");
                writer.WriteEncodedUrl(postUrl);
                writer.Write("\"/>");
            }

            writer.WriteEndTag("go");
        }
Ejemplo n.º 35
0
        public virtual void RenderSelectOptionAsPostBack(WmlTextWriter writer, string text, String target, String argument) {
            if (writer.AnalyzeMode) {
                return;
            }

            writer.WriteFullBeginTag("option");
            writer.WriteBeginTag("onevent");
            writer.WriteAttribute("type", "onpick");
            writer.Write(">");
            writer.WriteBeginTag("go");
            writer.WriteAttribute("href", "#" + WmlTextWriter.PostBackWithVarsCardID);
            writer.Write(">");
            if (!String.IsNullOrEmpty(target)) {
                writer.WriteBeginTag("setvar");
                writer.WriteAttribute("name", _postBackEventTargetVarName);
                writer.WriteAttribute("value", target);
                writer.Write(" />");
            }
            if (!String.IsNullOrEmpty(argument)) {
                writer.WriteBeginTag("setvar");
                writer.WriteAttribute("name", _postBackEventArgumentVarName);
                writer.WriteAttribute("value", argument);
                writer.Write(" />");
            }
            writer.WriteEndTag("go");
            writer.WriteEndTag("onevent");
            writer.WriteEncodedText(text);
            writer.WriteEndTag("option");
            _writtenPostBack = true;
            _usePostBackCards = true;
        }
Ejemplo n.º 36
0
        //     Renders the Form query string.
        private void RenderFormQueryString(WmlTextWriter writer, string queryString) {
            if (String.IsNullOrEmpty(queryString)) {
                return;
            }
            writer.Write("?");
            // 

            if (!StringUtil.EqualsIgnoreCase((string)Browser["canRenderOneventAndPrevElementsTogether"], "false")) {
                queryString = writer.ReplaceFormsCookieWithVariable(queryString);
            }
            writer.WriteEncodedText(queryString);
        }
Ejemplo n.º 37
0
        // Renders the beginning of the form.
        // 
        protected internal virtual void RenderBeginForm(WmlTextWriter writer) {

            RenderBeginCardTag(writer);

            // Write form variables.

            // 


            _writtenFormVariables = true;
            if (_formVariables == null) {
                _formVariables = new ListDictionary();
            }
            _formVariables[_postBackEventTargetVarName] = String.Empty; // Whidbey 18260
            _formVariables[_postBackEventArgumentVarName] = String.Empty;
            writer.Write("<onevent type=\"onenterforward\"><refresh>");
            RenderSetFormVariables(writer);
            RenderPostUrlFormVariable(writer);
            writer.WriteLine("</refresh></onevent>");
            writer.Write("<onevent type=\"onenterbackward\"><refresh>");
            RenderSetFormVariables(writer);
            RenderPostUrlFormVariable(writer);
            writer.WriteLine("</refresh></onevent>");
            // 
            writer.BeginFormOrPanel();
        }
Ejemplo n.º 38
0
        // Renders the beginning of the form.
        // UNDONE: Remove internal modifier when method is completely removed from writer.
        protected internal virtual void RenderBeginForm(WmlTextWriter writer) {

            RenderBeginCardTag(writer);

            // Write form variables.

            // UNDONE: Move writer._provideBackButton to this adapter.
            // Review: In V1 we had a writer.ProvideBackButton property, is there any need for this with (more advanced)
            // whidbey devices?
            _writtenFormVariables = true;
            if (_formVariables == null) {
                _formVariables = new ListDictionary();
            }
            _formVariables[_postBackEventTargetVarName] = String.Empty; // Whidbey 18260
            _formVariables[_postBackEventArgumentVarName] = String.Empty;
            writer.Write("<onevent type=\"onenterforward\"><refresh>");
            RenderSetFormVariables(writer);
            RenderPostUrlFormVariable(writer);
            writer.WriteLine("</refresh></onevent>");
            writer.Write("<onevent type=\"onenterbackward\"><refresh>");
            RenderSetFormVariables(writer);
            RenderPostUrlFormVariable(writer);
            writer.WriteLine("</refresh></onevent>");
            // UNDONE: formAdapter.RenderExtraCardElements(this);
            writer.BeginFormOrPanel();
        }
Ejemplo n.º 39
0
 private void RenderSetFormVariables(WmlTextWriter writer) {
     foreach (DictionaryEntry entry in _formVariables) {
         writer.WriteBeginTag("setvar");
         writer.WriteAttribute("name", (String)entry.Key);
         writer.WriteAttribute("value", (String)entry.Value, true);
         writer.Write(" />");
     }
 }
Ejemplo n.º 40
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.º 41
0
 //     Renders the cache expiry as a header or meta element.
 private void RenderCacheExpiry(WmlTextWriter writer) {
     if (!StringUtil.EqualsIgnoreCase(Browser["SupportsCacheControlMetaTag"], "false")) {
         writer.Write(_cacheExpiry);
     }
     else {
         Page.Response.AppendHeader("Cache-Control", "max-age=0");
     }
 }