コード例 #1
0
        private void RenderFormFields()
        {
            Control control;
            if (this.FormData != null)
            {
                FormsManager manager = FormsManager.GetManager();
                List<IControlsContainer> controlsContainers = new List<IControlsContainer>()
                {
                    this.FormData
                };
                List<ControlData> controlDatas = new List<ControlData>();

                typeof(PageHelper)
                    .GetMethod("ProcessControls", BindingFlags.Static | BindingFlags.NonPublic, null, CallingConventions.Any, new Type[] { typeof(IList<ControlData>), typeof(IList<ControlData>), typeof(IList<IControlsContainer>) }, null)
                    .Invoke(null, new object[] { new List<ControlData>(), controlDatas, controlsContainers });

                PlaceHoldersCollection placeHoldersCollection = new PlaceHoldersCollection();
                PlaceHolder placeHolder = new PlaceHolder()
                {
                    ID = "Body"
                };

                placeHoldersCollection.Add(placeHolder);

                List<ControlData> controlDatas1 = (List<ControlData>)typeof(PageHelper)
                    .GetMethod("SortControls", BindingFlags.Static | BindingFlags.NonPublic)
                    .Invoke(null, new object[] { controlsContainers.AsEnumerable<IControlsContainer>().Reverse<IControlsContainer>(), controlsContainers.Count });

                
                if (_isProgressiveForm)
                {
                    ControlData progressiveKeyFieldControlData = controlDatas1.Where(c => ((FormControl)c).Properties.Any(p => p.Name == "IsProgressiveKeyField" && p.Value == "True")).FirstOrDefault();

                    if (progressiveKeyFieldControlData != null)
                    {
                        FieldControl progressiveKeyFieldControl = manager.LoadControl(progressiveKeyFieldControlData, CultureInfo.CurrentUICulture) as FieldControl;

                        _progressiveKeyFieldName = Helpers.GetFieldName(progressiveKeyFieldControl);
                    }
                }

                foreach (ControlData controlDatum in controlDatas1)
                {
                    Control control1 = manager.LoadControl(controlDatum, CultureInfo.CurrentUICulture);

                    if (placeHoldersCollection.TryGetValue(controlDatum.PlaceHolder, out control))
                    {
                        if (control1 is FormSubmitButton)
                        {
                            this.ConfigureSubmitButton(control1, this.ValidationGroup);
                        }

                        bool showProgressiveField = ShowProgressiveField(control1);

                        if (control1 is FormSubmitButton || (_isProgressiveForm ? showProgressiveField : true))
                        {
                            control.Controls.Add(control1);
                        }

                        IFormFieldControl formFieldControl = control1 as IFormFieldControl;

                        if (formFieldControl != null & (control1 is FormSubmitButton || (_isProgressiveForm ? showProgressiveField : true)))
                        {
                            FieldControl fieldName = formFieldControl as FieldControl;

                            if (fieldName != null)
                            {
                                if (formFieldControl.MetaField != null && !string.IsNullOrEmpty(formFieldControl.MetaField.FieldName))
                                {
                                    fieldName.DataFieldName = formFieldControl.MetaField.FieldName;
                                }

                                fieldName.ValidationGroup = this.ValidationGroup;
                                fieldName.ValidatorDefinition.MessageCssClass = "sfError";
                                fieldName.ControlCssClassOnError = "sfErrorWrp";
                            }

                            this.FieldControls.Add(formFieldControl);
                        }
                    }

                    if (!(control1 is LayoutControl))
                    {
                        continue;
                    }

                    LayoutControl layoutControl = (LayoutControl)control1;

                    layoutControl.PlaceHolder = controlDatum.PlaceHolder;
                    placeHoldersCollection.AddRange(layoutControl.Placeholders);
                }
                this.FormControls.Controls.Add(placeHolder);
            }
        }
コード例 #2
0
        private void RenderFormFields()
        {
            Control control;

            if (this.FormData != null)
            {
                FormsManager manager = FormsManager.GetManager();
                List <IControlsContainer> controlsContainers = new List <IControlsContainer>()
                {
                    this.FormData
                };
                List <ControlData> controlDatas = new List <ControlData>();

                typeof(PageHelper)
                .GetMethod("ProcessControls", BindingFlags.Static | BindingFlags.NonPublic, null, CallingConventions.Any, new Type[] { typeof(IList <ControlData>), typeof(IList <ControlData>), typeof(IList <IControlsContainer>) }, null)
                .Invoke(null, new object[] { new List <ControlData>(), controlDatas, controlsContainers });

                PlaceHoldersCollection placeHoldersCollection = new PlaceHoldersCollection();
                PlaceHolder            placeHolder            = new PlaceHolder()
                {
                    ID = "Body"
                };

                placeHoldersCollection.Add(placeHolder);

                List <ControlData> controlDatas1 = (List <ControlData>) typeof(PageHelper)
                                                   .GetMethod("SortControls", BindingFlags.Static | BindingFlags.NonPublic)
                                                   .Invoke(null, new object[] { controlsContainers.AsEnumerable <IControlsContainer>().Reverse <IControlsContainer>(), controlsContainers.Count });


                if (_isProgressiveForm)
                {
                    ControlData progressiveKeyFieldControlData = controlDatas1.Where(c => ((FormControl)c).Properties.Any(p => p.Name == "IsProgressiveKeyField" && p.Value == "True")).FirstOrDefault();

                    if (progressiveKeyFieldControlData != null)
                    {
                        FieldControl progressiveKeyFieldControl = manager.LoadControl(progressiveKeyFieldControlData, CultureInfo.CurrentUICulture) as FieldControl;

                        _progressiveKeyFieldName = Helpers.GetFieldName(progressiveKeyFieldControl);
                    }
                }

                foreach (ControlData controlDatum in controlDatas1)
                {
                    Control control1 = manager.LoadControl(controlDatum, CultureInfo.CurrentUICulture);

                    if (placeHoldersCollection.TryGetValue(controlDatum.PlaceHolder, out control))
                    {
                        if (control1 is FormSubmitButton)
                        {
                            this.ConfigureSubmitButton(control1, this.ValidationGroup);
                        }

                        bool showProgressiveField = ShowProgressiveField(control1);

                        if (control1 is FormSubmitButton || (_isProgressiveForm ? showProgressiveField : true))
                        {
                            control.Controls.Add(control1);
                        }

                        IFormFieldControl formFieldControl = control1 as IFormFieldControl;

                        if (formFieldControl != null & (control1 is FormSubmitButton || (_isProgressiveForm ? showProgressiveField : true)))
                        {
                            FieldControl fieldName = formFieldControl as FieldControl;

                            if (fieldName != null)
                            {
                                if (formFieldControl.MetaField != null && !string.IsNullOrEmpty(formFieldControl.MetaField.FieldName))
                                {
                                    fieldName.DataFieldName = formFieldControl.MetaField.FieldName;
                                }

                                fieldName.ValidationGroup = this.ValidationGroup;
                                fieldName.ValidatorDefinition.MessageCssClass = "sfError";
                                fieldName.ControlCssClassOnError = "sfErrorWrp";
                            }

                            this.FieldControls.Add(formFieldControl);
                        }
                    }

                    if (!(control1 is LayoutControl))
                    {
                        continue;
                    }

                    LayoutControl layoutControl = (LayoutControl)control1;

                    layoutControl.PlaceHolder = controlDatum.PlaceHolder;
                    placeHoldersCollection.AddRange(layoutControl.Placeholders);
                }
                this.FormControls.Controls.Add(placeHolder);
            }
        }