Exemplo n.º 1
0
        public override void Render(WmlMobileTextWriter writer)
        {
            String formsAuthCookieName = FormsAuthentication.FormsCookieName;

            if (!Device.SupportsRedirectWithCookie)
            {
                if (formsAuthCookieName != String.Empty)
                {
                    HttpContext.Current.Response.Cookies.Remove(formsAuthCookieName);
                }
            }

            writer.BeginForm(Control);
            if (Page.Adapter.PersistCookielessData &&
                Device.CanRenderOneventAndPrevElementsTogether &&
                formsAuthCookieName != null &&
                formsAuthCookieName != String.Empty &&
                Control == Page.ActiveForm)
            {
                IDictionary dictionary = PageAdapter.CookielessDataDictionary;
                if (dictionary != null)
                {
                    String value = (String)dictionary[formsAuthCookieName];
                    if ((value != null) && (value != String.Empty))
                    {
                        writer.AddFormVariable("__facn", value, false);
                    }
                }
            }
            MobileControl secondaryUIControl = SecondaryUIControl as MobileControl;

            writer.EnterLayout(Style);
            if (secondaryUIControl != null && secondaryUIControl.Form == Control)
            {
                SetControlPageRecursive(secondaryUIControl, -1);
                secondaryUIControl.RenderControl(writer);
            }
            else
            {
                if (Control.HasControls())
                {
                    Panel header = Control.Header;
                    Panel footer = Control.Footer;

                    if (header != null)
                    {
                        writer.BeginCustomMarkup();
                        header.RenderControl(writer);
                        writer.EndCustomMarkup();
                    }

                    foreach (Control control in Control.Controls)
                    {
                        if (control != header && control != footer)
                        {
                            control.RenderControl(writer);
                        }
                    }

                    RenderPager(writer);

                    if (footer != null)
                    {
                        writer.BeginCustomMarkup();
                        footer.RenderControl(writer);
                        writer.EndCustomMarkup();
                    }
                }
                else
                {
                    RenderPager(writer);
                }
            }
            writer.ExitLayout(Style);
            writer.EndForm();
        }
        /// <include file='doc\HtmlFormAdapter.uex' path='docs/doc[@for="HtmlFormAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            Color  backColor    = (Color)Style[Style.BackColorKey, true];
            String title        = Control.Title;
            bool   isTitleEmpty = String.IsNullOrEmpty(title);

            bool willWriteHeadElements =
                !isTitleEmpty ||
                RenderExtraHeadElements(null);

            if (willWriteHeadElements)
            {
                writer.Write("\r\n");
                writer.WriteFullBeginTag("head");
            }

            if (!isTitleEmpty)
            {
                writer.Write("\r\n");
                writer.WriteFullBeginTag("title");
                writer.Write(title);
                writer.WriteEndTag("title");
                writer.Write("\r\n");
            }

            _renderPager = true;

            RenderExtraHeadElements(writer);

            if (willWriteHeadElements)
            {
                writer.WriteEndTag("head");
                writer.Write("\r\n");
            }

            IDictionary bodyAttributes = new ListDictionary();

            if ((backColor != Color.Empty) && (writer.RenderBodyColor))
            {
                bodyAttributes.Add("bgcolor", ColorTranslator.ToHtml(backColor));
            }
            RenderBodyTag(writer, bodyAttributes);

            bool formTagRequired = ShouldRenderFormTag();

            if (formTagRequired)
            {
                writer.WriteBeginTag("form");
                writer.WriteAttribute("id", Control.ClientID);
                writer.WriteAttribute("name", Control.ClientID);
                writer.WriteAttribute("method", Control.Method.ToString().ToLower(CultureInfo.InvariantCulture));
                writer.Write(" action=\"");

                if (Control.Action.Length > 0)
                {
                    // AUI 3652
                    String url = Control.ResolveUrl(Control.Action);

                    if (!Device.SupportsQueryStringInFormAction)
                    {
                        // If query string is not supported, we don't write
                        // it here, and the query string will be added as
                        // hidden variables later.
                        int i = url.IndexOf('?');
                        if (i != -1)
                        {
                            url = url.Substring(0, i);
                        }
                    }

                    writer.Write(url);
                }
                else
                {
                    writer.WriteEncodedUrl(Page.RelativeFilePath);

                    if (Device.SupportsQueryStringInFormAction)
                    {
                        writer.Write("?");
                        writer.Write(Page.UniqueFilePathSuffix);
                        if (Control.Method != FormMethod.Get)
                        {
                            String queryStringText = Page.QueryStringText;
                            if (queryStringText != null && queryStringText.Length > 0)
                            {
                                writer.Write('&');
                                writer.Write(queryStringText);
                            }
                        }
                    }
                }

                writer.Write("\"");
                writer.Write(">\r\n");

                PageAdapter.RenderPostBackHeader(writer, Control);

                // Renders hidden variables for IPostBackDataHandlers which are
                // not displayed due to pagination or secondary UI.
                RenderOffPageVariables(writer, Control, Control.CurrentPage);
            }

            writer.EnterStyle(Style);

            writer.BeforeFirstControlWritten = true;

            MobileControl secondaryUIControl = SecondaryUIControl as MobileControl;

            if (secondaryUIControl != null && secondaryUIControl.Form == Control)
            {
                bool secondaryUIInHeaderOrFooter = IsControlInFormHeader(secondaryUIControl) ||
                                                   IsControlInFormFooter(secondaryUIControl);


                SetControlPageRecursive(secondaryUIControl, -1);
                if (Control.Header != null && !secondaryUIInHeaderOrFooter)
                {
                    Control.Header.RenderControl(writer);
                }
                secondaryUIControl.RenderControl(writer);
                if (Control.Footer != null && !secondaryUIInHeaderOrFooter)
                {
                    Control.Footer.RenderControl(writer);
                }
            }
            else
            {
                bool pagerRendered = false;
                if (Control.HasControls())
                {
                    foreach (Control child in Control.Controls)
                    {
                        if (Control.Footer == child)
                        {
                            RenderPager(writer);
                            pagerRendered = true;
                        }
                        child.RenderControl(writer);
                    }
                }
                if (!pagerRendered)
                {
                    RenderPager(writer);
                }
            }

            writer.ExitStyle(Style, false);

            if (formTagRequired)
            {
                if (!Device.SupportsQueryStringInFormAction)
                {
                    // Add query string parameters at the end of the form if
                    // there are any
                    RenderQueryParametersAsHiddenFields(writer);
                }
                writer.WriteEndTag("form");
            }
            writer.WriteEndTag("body");
        }