Exemplo n.º 1
0
        private void BuildControlPostBacksRecursive(Control control)
        {
            if (control is IPostBackDataHandler &&
                !(control is IPostBackEventHandler) &&
                control.Visible && control != Control)
            {
                MobileControl mobileCtl = control as MobileControl;

                if (mobileCtl != null && !mobileCtl.IsVisibleOnPage(Control.CurrentPage))
                {
                    String s = GetControlPostBackValue(mobileCtl);
                    if (s != null)
                    {
                        _postBackVariables[control] = s;
                    }
                }
                else
                {
                    _postBackVariables[control] = null;
                }
            }

            if (control.HasControls())
            {
                foreach (Control child in control.Controls)
                {
                    BuildControlPostBacksRecursive(child);
                }
            }
        }
        // Renders hidden variables for IPostBackDataHandlers which are
        // not displayed due to pagination or secondary UI.
        internal void RenderOffPageVariables(HtmlMobileTextWriter writer, Control ctl, int page)
        {
            if (ctl.HasControls())
            {
                foreach (Control child in ctl.Controls)
                {
                    // Note: Control.Form != null.
                    if (!child.Visible || child == Control.Form.Header || child == Control.Form.Footer)
                    {
                        continue;
                    }

                    MobileControl mobileCtl = child as MobileControl;

                    if (mobileCtl != null)
                    {
                        if (mobileCtl.IsVisibleOnPage(page) &&
                            (mobileCtl == ((HtmlFormAdapter)mobileCtl.Form.Adapter).SecondaryUIControl ||
                             null == ((HtmlFormAdapter)mobileCtl.Form.Adapter).SecondaryUIControl))
                        {
                            if (mobileCtl.FirstPage == mobileCtl.LastPage)
                            {
                                // Entire control is visible on this page, so no need to look
                                // into children.
                                continue;
                            }

                            // Control takes up more than one page, so it may be possible that
                            // its children are on a different page, so we'll continue to
                            // fall through into children.
                        }
                        else if (mobileCtl is IPostBackDataHandler)
                        {
                            HtmlControlAdapter adapter = mobileCtl.Adapter as HtmlControlAdapter;
                            if (adapter != null)
                            {
                                adapter.RenderAsHiddenInputField(writer);
                            }
                        }
                    }

                    RenderOffPageVariables(writer, child, page);
                }
            }
        }