Ejemplo n.º 1
0
 public void AddAt(int index, TableCell cell)
 {
     if (cc.IndexOf(cell) < 0)
     {
         cc.AddAt(index, cell);
     }
 }
Ejemplo n.º 2
0
        public void HtmlTableRowControlCollectionAddAt()
        {
            TestHtmlTable     t = new TestHtmlTable();
            ControlCollection c = t.GetCollection();

            c.AddAt(0, new HtmlTableRow());
            c.AddAt(0, new InheritedHtmlTableRow());
            Assert.AreEqual(2, c.Count, "Rows");
        }
Ejemplo n.º 3
0
    // Creates a new urlgeneratorcollection. Accepts the modules controls, ajaxmanager and control to position it to (usually null)
    public UrlGeneratorCollection(ControlCollection _controls, RadAjaxManager aManager, Control aControlPos)
    {
        // Creates a list of parameters controls
        _listOfControlObject = new List <ParameterControl>();

        // Creates a button that generates the data url
        RadButton _urlGenerator = new RadButton();

        _urlGenerator.Text       = "Get data url";
        _urlGenerator.ID         = "STATIC_URLGENERATOR_BUTTON";
        _urlGenerator.Click     += FindUrl;             // Generates url
        _urlGenerator.RenderMode = RenderMode.Lightweight;
        _urlGenerator.Style.Add("float", "right");
        _urlGenerator.Icon.SecondaryIconCssClass = "rbSearch";
        _urlGenerator.Icon.SecondaryIconRight    = 5;

        // Create a new ajax setting
        AjaxSetting _buttonCtrl = new AjaxSetting(_urlGenerator.ID);

        // Fake label that the radwindow is added to
        _controlWindowHolder    = new Label();
        _controlWindowHolder.ID = "LABEL_WINDOWHOLDER";

        // Add both the radbutton
        AjaxUpdatedControl _ctrlButton = new AjaxUpdatedControl();

        _ctrlButton.ControlID             = _urlGenerator.ID;
        _ctrlButton.UpdatePanelRenderMode = UpdatePanelRenderMode.Block;
        // And the label
        AjaxUpdatedControl _ctrl_Label = new AjaxUpdatedControl();

        _ctrl_Label.ControlID             = _controlWindowHolder.ID;
        _ctrl_Label.UpdatePanelRenderMode = UpdatePanelRenderMode.Block;
        // To the AjaxSetting
        _buttonCtrl.UpdatedControls.Add(_ctrlButton);
        _buttonCtrl.UpdatedControls.Add(_ctrl_Label);
        // Now add the ajaxsetting to the modules ajaxcontroller
        aManager.AjaxSettings.Add(_buttonCtrl);

        // Find the controls index in the control collection
        int _indexOfGrid = _controls.IndexOf(aControlPos);

        //If the control is found, anchor before it
        if (_indexOfGrid >= 0)
        {
            _controls.AddAt(_indexOfGrid, _controlWindowHolder);
            _controls.AddAt(_indexOfGrid, _urlGenerator);
        }
        else // if not, add to top
        {
            _controls.AddAt(0, _controlWindowHolder);
            _controls.AddAt(0, _urlGenerator);
        }
    }
Ejemplo n.º 4
0
        private void AddParentRecursive(ControlCollection controls, MenuItem mi)
        {
            if (mi.parent != null)
            {
                LiteralControl lc = new LiteralControl();
                lc.Text = " > ";
                controls.AddAt(0, lc);
                controls.AddAt(0, BuildLink(mi.parent));

                AddParentRecursive(controls, mi.parent);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Adds a specified control after another existing control in this collection.
        /// </summary>
        public static void AddAfter(this ControlCollection container, Control existingControl, Control newControl)
        {
            if (existingControl == null)
            {
                throw new ArgumentNullException("existingControl");
            }

            if (newControl == null)
            {
                throw new ArgumentNullException("newControl");
            }

            var index = container.IndexOf(existingControl);

            if (index == -1)
            {
                throw new ArgumentException(existingControl + " (" + existingControl.ID + ") does is not a child of this controls container.");
            }

            if (index == container.Count - 1)
            {
                container.Add(newControl);
            }
            else
            {
                container.AddAt(index + 1, newControl);
            }
        }
Ejemplo n.º 6
0
 public void AddAt(int index, TableRow row)
 {
     if (row == null)
     {
         throw new NullReferenceException();                  // .NET compatibility
     }
     if (cc.IndexOf(row) < 0)
     {
         if (row.TableRowSectionSet)
         {
             owner.GenerateTableSections = true;
         }
         row.Container = this;
         cc.AddAt(index, row);
     }
 }
Ejemplo n.º 7
0
        public void HtmlTableRowControlCollectionAddAt_Null()
        {
            TestHtmlTable     t = new TestHtmlTable();
            ControlCollection c = t.GetCollection();

            c.AddAt(0, null);
        }
Ejemplo n.º 8
0
        public void HtmlTableRowControlCollectionAddAt_WrongType()
        {
            TestHtmlTable     t = new TestHtmlTable();
            ControlCollection c = t.GetCollection();

            c.AddAt(0, new HtmlTable());
        }
Ejemplo n.º 9
0
        public static void AddAt(this ControlCollection ctrl, int index, string literal)
        {
            if (ctrl == null)
            {
                throw new NullReferenceException();
            }
            if (string.IsNullOrEmpty(literal))
            {
                return;
            }

            ctrl.AddAt(index, new LiteralControl(literal));
        }
Ejemplo n.º 10
0
        protected override void AddControlOnTemplate(object viewSiteControl, object control, AdditionalViewControlsProviderPosition position)
        {
            ControlCollection collection = ((Control)viewSiteControl).Controls;

            if (position == AdditionalViewControlsProviderPosition.Top)
            {
                collection.AddAt(0, (Control)control);
            }
            else
            {
                collection.Add((Control)control);
            }
        }
Ejemplo n.º 11
0
        protected override void OnInit(EventArgs e)
        {
            // Init
            PlaceHolder       plc;
            ControlCollection col = this.Controls;

            // Set template directory
            if (this._templateDir == null && ConfigurationManager.AppSettings["TemplateDir"] != null)
            {
                this._templateDir = ConfigurationManager.AppSettings["TemplateDir"];
            }

            // Get the template control
            if (this._templateFilename == null)
            {
                this._templateFilename = ConfigurationManager.AppSettings["DefaultTemplate"];
            }

            this._pageControl = (BasePageControl)this.LoadControl(this.ResolveUrl(this._templateDir + this._templateFilename));

            // Add the pagecontrol on top of the control collection of the page
            _pageControl.ID = "p";
            col.AddAt(0, _pageControl);

            // Get the Content placeholder
            plc = _pageControl.Content;
            if (plc != null)
            {
                // Iterate through the controls in the page to find the form control.
                foreach (Control control in col)
                {
                    if (control is HtmlForm)
                    {
                        // We've found the form control. Now move all child controls into the placeholder.
                        HtmlForm formControl = (HtmlForm)control;
                        while (formControl.Controls.Count > 0)
                        {
                            plc.Controls.Add(formControl.Controls[0]);
                        }
                    }
                }
                // throw away all controls in the page, except the page control
                while (col.Count > 1)
                {
                    col.Remove(col[1]);
                }
            }
            base.OnInit(e);
        }
Ejemplo n.º 12
0
        public void Deny_Unrestricted()
        {
            // note: using the same control (as owner) to add results
            // in killing the ms runtime with a stackoverflow - FDBK36722
            ControlCollection cc = new ControlCollection(new Control());

            Assert.AreEqual(0, cc.Count, "Count");
            Assert.IsFalse(cc.IsReadOnly, "IsReadOnly");
            Assert.IsFalse(cc.IsSynchronized, "IsSynchronized");
            Assert.IsNotNull(cc.SyncRoot, "SyncRoot");

            cc.Add(control);
            Assert.IsNotNull(cc[0], "this[int]");
            cc.Clear();
            cc.AddAt(0, control);
            Assert.IsTrue(cc.Contains(control), "Contains");

            cc.CopyTo(new Control[1], 0);
            Assert.IsNotNull(cc.GetEnumerator(), "GetEnumerator");
            Assert.AreEqual(0, cc.IndexOf(control), "IndexOf");
            cc.RemoveAt(0);
            cc.Remove(control);
        }
        public static void AddAfter(this ControlCollection collection, Control after, Control control)
        {
            int indexFound   = -1;
            int currentIndex = 0;

            foreach (Control controlToEvaluate in collection)
            {
                if (controlToEvaluate == after)
                {
                    indexFound = currentIndex;
                    break;
                }

                currentIndex = currentIndex + 1;
            }

            if (indexFound == -1)
            {
                throw new ArgumentOutOfRangeException("control", "Control not found");
            }

            collection.AddAt(indexFound + 1, control);
        }
Ejemplo n.º 14
0
    private void ClearReport()
    {
        ControlCollection coll = this.ReportViewer1.Parent.Controls;

        //remember the place, there the old ReportViewer was

        int oldIndex = coll.IndexOf(this.ReportViewer1);

        //remove in from the page

        coll.Remove(this.ReportViewer1);

        //then add new control

        ReportViewer1 = new Microsoft.Reporting.WebForms.ReportViewer();

        ReportViewer1.Height = Unit.Parse("490px");

        ReportViewer1.Width = Unit.Parse("100%");

        coll.AddAt(oldIndex, ReportViewer1);

        this.ReportViewer1.LocalReport.DataSources.Clear();
    }
Ejemplo n.º 15
0
 private void ConvertPersistedControlsToLiteralControls(Control defaultTemplateContents)
 {
     foreach (string str in this.PersistedControlIDs)
     {
         Control control = defaultTemplateContents.FindControl(str);
         if (control != null)
         {
             if (Array.IndexOf <string>(this.PersistedIfNotVisibleControlIDs, str) >= 0)
             {
                 control.Visible               = true;
                 control.Parent.Visible        = true;
                 control.Parent.Parent.Visible = true;
             }
             if (control.Visible)
             {
                 LiteralControl    child    = new LiteralControl(ControlPersister.PersistControl(control, this._designerHost));
                 ControlCollection controls = control.Parent.Controls;
                 int index = controls.IndexOf(control);
                 controls.Remove(control);
                 controls.AddAt(index, child);
             }
         }
     }
 }
Ejemplo n.º 16
0
        protected override void OnInit(EventArgs e)
        {
            // Init
            PlaceHolder       plc = null;
            ControlCollection col = Controls;

            // Set template directory
            if (_templateDir == null && ConfigurationSettings.AppSettings["TemplateDir"] != null)
            {
                _templateDir = ConfigurationSettings.AppSettings["TemplateDir"];
            }

            // Get the template control
            if (_templateFilename == null)
            {
                _templateFilename = ConfigurationSettings.AppSettings["DefaultTemplate"];
            }
            BasePageControl pageControl = (BasePageControl)LoadControl(ResolveUrl(_templateDir + _templateFilename));

            // Add the pagecontrol on top of the control collection of the page
            pageControl.ID = "p";
            col.AddAt(0, pageControl);

            // Get the Content placeholder
            plc = pageControl.Content;
            if (plc != null)
            {
                // Iterate through the controls in the page to find the form control.
                foreach (Control control in col)
                {
                    if (control is HtmlForm)
                    {
                        // We've found the form control. Now move all child controls into the placeholder.
                        HtmlForm formControl = (HtmlForm)control;
                        while (formControl.Controls.Count > 0)
                        {
                            // Updated 10/04/2008: Support UpdatePanel by Kien
                            if (formControl.Controls[0] is UpdatePanel)
                            {
                                UpdatePanel updatepanel = new UpdatePanel();
                                UpdatePanel oldPanel    = (UpdatePanel)formControl.Controls[0];
                                while (oldPanel.ContentTemplateContainer.Controls.Count > 0)
                                {
                                    updatepanel.ContentTemplateContainer.Controls.Add(
                                        oldPanel.ContentTemplateContainer.Controls[0]);
                                }
                                plc.Controls.Add(updatepanel);
                                formControl.Controls.RemoveAt(0);
                            }
                            else
                            {
                                plc.Controls.Add(formControl.Controls[0]);
                            }
                        }
                    }
                }
                // throw away all controls in the page, except the page control
                while (col.Count > 1)
                {
                    col.Remove(col[1]);
                }
            }
            base.OnInit(e);
        }
Ejemplo n.º 17
0
 public void Insert(int index, HtmlTableRow row)
 {
     cc.AddAt(index, row);
 }
 public void Insert(int index, HtmlTableCell cell)
 {
     cc.AddAt(index, cell);
 }
        private static void BaseEventHandler(string consoleId,
                                             string elementProviderName,
                                             FlowToken flowToken,
                                             FormFlowUiDefinition formFlowUiCommand,
                                             FlowControllerServicesContainer servicesContainer,
                                             Dictionary <IFormEventIdentifier, FormFlowEventHandler> eventHandlers,
                                             IFormEventIdentifier localScopeEventIdentifier,
                                             FlowControllerServicesContainer formServicesContainer)
        {
            FormTreeCompiler            activeFormTreeCompiler  = CurrentFormTreeCompiler;
            Dictionary <string, object> activeInnerFormBindings = CurrentInnerFormBindings;

            FormFlowEventHandler           handler       = eventHandlers[localScopeEventIdentifier];
            Dictionary <string, Exception> bindingErrors = activeFormTreeCompiler.SaveAndValidateControlProperties();

            FormTreeCompiler activeCustomToolbarFormTreeCompiler = CurrentCustomToolbarFormTreeCompiler;

            if (activeCustomToolbarFormTreeCompiler != null)
            {
                var toolbarBindingErrors = activeCustomToolbarFormTreeCompiler.SaveAndValidateControlProperties();
                foreach (var pair in toolbarBindingErrors)
                {
                    bindingErrors.Add(pair.Key, pair.Value);
                }
            }

            formServicesContainer.AddService(new BindingValidationService(bindingErrors));

            handler.Invoke(flowToken, activeInnerFormBindings, formServicesContainer);

            if (formServicesContainer.GetService <IManagementConsoleMessageService>().CloseCurrentViewRequested)
            {
                ViewTransitionHelper.HandleCloseCurrentView(formFlowUiCommand.UiContainerType);
                return;
            }

            var  formFlowService   = formServicesContainer.GetService <IFormFlowRenderingService>();
            bool replacePageOutput = (formServicesContainer.GetService <IFormFlowWebRenderingService>().NewPageOutput != null);

            bool rerenderView = formFlowService.RerenderViewRequested;

            if (formFlowService.BindingPathedMessages != null)
            {
                ShowFieldMessages(CurrentControlTreeRoot, formFlowService.BindingPathedMessages, CurrentControlContainer,
                                  servicesContainer);
            }

            List <bool> boolCounterList = new List <bool> {
                replacePageOutput, rerenderView
            };

            if (boolCounterList.Count(f => f) > 1)
            {
                StringBuilder sb = new StringBuilder("Flow returned conflicting directives for post handling:\n");
                if (replacePageOutput)
                {
                    sb.AppendLine(" - Replace page output with new web control.");
                }
                if (rerenderView)
                {
                    sb.AppendLine(" - Rerender view.");
                }

                throw new InvalidOperationException(sb.ToString());
            }

            if (rerenderView)
            {
                Log.LogVerbose("FormFlowRendering", "Re-render requested");
                IFlowUiDefinition newFlowUiDefinition = FlowControllerFacade.GetCurrentUiDefinition(flowToken,
                                                                                                    servicesContainer);
                if (!(newFlowUiDefinition is FlowUiDefinitionBase))
                {
                    throw new NotImplementedException("Unable to handle transitions to ui definition of type " +
                                                      newFlowUiDefinition.GetType());
                }
                ViewTransitionHelper.HandleRerender(consoleId, elementProviderName, flowToken, formFlowUiCommand,
                                                    (FlowUiDefinitionBase)newFlowUiDefinition, servicesContainer);
            }

            if (replacePageOutput)
            {
                Log.LogVerbose("FormFlowRendering", "Replace pageoutput requested");
                IFormFlowWebRenderingService webRenderingService =
                    formServicesContainer.GetService <IFormFlowWebRenderingService>();
                Control newPageOutput = webRenderingService.NewPageOutput;

                foreach (Control control in GetNestedControls(newPageOutput).Where(f => f is ScriptManager).ToList())
                {
                    control.Parent.Controls.Remove(control);
                }

                Page currentPage = HttpContext.Current.Handler as Page;

                HtmlHead newHeadControl = GetNestedControls(newPageOutput).FirstOrDefault(f => f is HtmlHead) as HtmlHead;

                HtmlHead oldHeadControl = currentPage.Header;

                ControlCollection headContainer = null;
                bool headersHasToBeSwitched     = newHeadControl != null && oldHeadControl != null;
                if (headersHasToBeSwitched)
                {
                    headContainer = newHeadControl.Parent.Controls;
                    headContainer.Remove(newHeadControl);
                }

                currentPage.Controls.Clear();
                if (string.IsNullOrEmpty(webRenderingService.NewPageMimeType))
                {
                    currentPage.Response.ContentType = "text/html";
                }
                else
                {
                    currentPage.Response.ContentType = webRenderingService.NewPageMimeType;
                }
                currentPage.Controls.Add(newPageOutput);

                if (headersHasToBeSwitched)
                {
                    oldHeadControl.Controls.Clear();
                    oldHeadControl.InnerHtml = "";
                    oldHeadControl.InnerText = "";
                    if (newHeadControl.ID != null)
                    {
                        oldHeadControl.ID = newHeadControl.ID;
                    }
                    oldHeadControl.Title = newHeadControl.Title;

                    headContainer.AddAt(0, oldHeadControl);

                    foreach (Control c in newHeadControl.Controls.Cast <Control>().ToList())
                    {
                        oldHeadControl.Controls.Add(c);
                    }
                }
            }
        }
Ejemplo n.º 20
0
        protected override void OnInit(EventArgs e)
        {
            // The GeneralPage loads it's own content. No need for the PageEngine to do that.
            base.ShouldLoadContent = false;
            // Init the PageEngine.
            base.OnInit(e);
            // Build page.
            ControlCollection col = this.Controls;

            this._currentSite = base.RootNode.Site;
            if (this._currentSite.DefaultTemplate != null &&
                this._currentSite.DefaultPlaceholder != null &&
                this._currentSite.DefaultPlaceholder != String.Empty)
            {
                // Load the template
                this.TemplateControl = (BaseTemplate)this.LoadControl(UrlHelper.GetApplicationPath()
                                                                      + this._currentSite.DefaultTemplate.Path);
                // Register css
                string css = UrlHelper.GetApplicationPath()
                             + this._currentSite.DefaultTemplate.BasePath
                             + "/Css/" + this._currentSite.DefaultTemplate.Css;
                RegisterStylesheet("maincss", css);

                if (this._title != null)
                {
                    this.TemplateControl.Title = this._title;
                }

                // Add the pagecontrol on top of the control collection of the page
                this.TemplateControl.ID = "p";
                col.AddAt(0, this.TemplateControl);

                // Get the Content placeholder
                this._contentPlaceHolder = this.TemplateControl.FindControl(this._currentSite.DefaultPlaceholder) as PlaceHolder;
                if (this._contentPlaceHolder != null)
                {
                    // Iterate through the controls in the page to find the form control.
                    foreach (Control control in col)
                    {
                        if (control is HtmlForm)
                        {
                            // We've found the form control. Now move all child controls into the placeholder.
                            HtmlForm formControl = (HtmlForm)control;
                            while (formControl.Controls.Count > 0)
                            {
                                this._contentPlaceHolder.Controls.Add(formControl.Controls[0]);
                            }
                        }
                    }
                    // throw away all controls in the page, except the page control
                    while (col.Count > 1)
                    {
                        col.Remove(col[1]);
                    }
                }
            }
            else
            {
                // The default template and placeholders are not correctly configured.
                throw new Exception("Unable to display page because the default template is not configured.");
            }
        }
        /// <summary>
        ///     The create number 1.
        /// </summary>
        /// <param name="control">
        ///     The control.
        /// </param>
        /// <param name="request">
        ///     The request.
        /// </param>
        private static void createNumber1(Control control, HttpRequest request)
        {
            ControlCollection col = control.Controls;

            foreach (Control ctrl in col)
            {
                if (ctrl is Label)
                {
                    var lb = ctrl as Label;
                    if (lb.Text == "1")
                    {
                        var    lbt         = new HyperLink();
                        string queryString = request.QueryString["ispage"];
                        if (queryString != null)
                        {
                            NameValueCollection coll = request.QueryString;
                            string[]            arr  = coll.AllKeys;
                            var myStringBuilder      = new StringBuilder();
                            for (int i = 0; i < arr.Length; i++)
                            {
                                if (arr[i] != "ispage")
                                {
                                    myStringBuilder.AppendFormat("{0}={1}&", arr[i], coll[arr[i]]);
                                }
                            }

                            if (ctrl.Page is ProductDetail)
                            {
                                lbt.NavigateUrl = string.Format("{0}?{1}ispage=1", "~/Ordering/ProductDetail.aspx",
                                                                myStringBuilder);
                            }
                            else
                            {
                                lbt.NavigateUrl = string.Format("{0}?{1}ispage=1", "~/Ordering/Catalog.aspx",
                                                                myStringBuilder);
                            }
                        }
                        else
                        {
                            if (ctrl.Page is ProductDetail)
                            {
                                lbt.NavigateUrl = string.Format("{0}?{1}&ispage=1", "~/Ordering/ProductDetail.aspx",
                                                                request.QueryString);
                            }
                            else
                            {
                                lbt.NavigateUrl = string.Format("{0}?{1}&ispage=1", "~/Ordering/Catalog.aspx",
                                                                request.QueryString);
                            }
                        }

                        lbt.Text = "1";

                        // lbt.CommandArgument = "1";
                        // lbt.CommandName = "0";
                        col.AddAt(0, lbt);
                        col.Remove(lb);
                        break;
                    }
                }
            }
        }