コード例 #1
0
        /// <include file='doc\WmlControlAdapter.uex' path='docs/doc[@for="WmlControlAdapter.RenderBeginLink"]/*' />
        protected void RenderBeginLink(WmlMobileTextWriter writer, 
                                       String targetUrl, 
                                       String softkeyLabel, 
                                       bool implicitSoftkeyLabel,
                                       bool mapToSoftkey)
        {
            if (mapToSoftkey && !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(LinkLabel);
                    implicitSoftkeyLabel = true;
                }
            }

            String postback = DeterminePostBack(targetUrl);
            
            if (postback != null)
            {
                writer.RenderBeginPostBack(softkeyLabel, implicitSoftkeyLabel, mapToSoftkey);
            }
            else
            {
                String prefix = Constants.FormIDPrefix;
                if (targetUrl.StartsWith(prefix, StringComparison.Ordinal))
                {
                    String formID = targetUrl.Substring(prefix.Length);
                    Form form = Control.ResolveFormReference(formID);
                    targetUrl = prefix + form.ClientID;
                }
                else
                {
                    bool absoluteUrl = ( (targetUrl.StartsWith("http:", StringComparison.Ordinal)) || (targetUrl.StartsWith("https:", StringComparison.Ordinal)) );
                    // AUI 3652
                    targetUrl = Control.ResolveUrl(targetUrl);
                    bool queryStringWritten = targetUrl.IndexOf('?') != -1; 
                    IDictionary dictionary = PageAdapter.CookielessDataDictionary;
                    String formsAuthCookieName = FormsAuthentication.FormsCookieName;
                    if((dictionary != null) && (!absoluteUrl) && (Control.MobilePage.Adapter.PersistCookielessData))
                    {
                        StringBuilder sb = new StringBuilder(targetUrl);

                        foreach(String name in dictionary.Keys)
                        {
                            if(queryStringWritten)
                            {
                                sb.Append("&amp;");
                            }
                            else
                            {
                                sb.Append("?");
                                queryStringWritten = true;
                            }

                            if(name.Equals(formsAuthCookieName) && Device.CanRenderOneventAndPrevElementsTogether )
                            {
                                sb.Append(name);
                                sb.Append("=$(");
                                sb.Append(writer.MapClientIDToShortName("__facn",false));
                                sb.Append(")");
                            }
                            else
                            {
                                sb.Append(name);
                                sb.Append("=");
                                sb.Append(dictionary[name]);
                            }
                        }
                        targetUrl = sb.ToString();
                    }
                }

                writer.RenderBeginHyperlink(targetUrl, 
                                            false, 
                                            softkeyLabel, 
                                            implicitSoftkeyLabel, 
                                            mapToSoftkey);
            }
        }
コード例 #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);
        }