コード例 #1
0
ファイル: BasePage.cs プロジェクト: dolani/CodeTorch
        private BaseSectionControl GetSectionControl(Screen screen, Section section, string ResourceKeyPrefix)
        {
            BaseSectionControl sectionControl = null;
            SectionType        sectionType    = SectionType.GetSectionType(section);

            if (sectionType != null)
            {
                if (!String.IsNullOrEmpty(sectionType.Assembly) && !String.IsNullOrEmpty(sectionType.Class))
                {
                    sectionControl = (BaseSectionControl)Activator.CreateInstance(sectionType.Assembly, sectionType.Class).Unwrap();
                }


                if (sectionControl != null)
                {
                    sectionControl.Screen            = screen;
                    sectionControl.Section           = section;
                    sectionControl.ResourceKeyPrefix = ResourceKeyPrefix;

                    sectionControl.RenderControl();
                }
            }

            return(sectionControl);
        }
コード例 #2
0
ファイル: BasePage.cs プロジェクト: dolani/CodeTorch
        private void RenderSection(HtmlGenericControl div, Screen screen, Section section, string ResourceKeyPrefix)
        {
            bool RenderSection = section.Visible;

            try
            {
                if (section.Permission.CheckPermission)
                {
                    RenderSection = Common.HasPermission(section.Permission.Name);
                }


                BaseSectionControl sectionControl = GetSectionControl(screen, section, ResourceKeyPrefix);

                if (!sectionControl.Visible)
                {
                    RenderSection = false;
                }

                if (sectionControl != null)
                {
                    if (String.IsNullOrEmpty(section.ID))
                    {
                        if (!String.IsNullOrEmpty(section.Name))
                        {
                            sectionControl.ID = section.Name.Trim().Replace(' ', '_').Replace('&', '_').Replace("'", "_");
                        }
                    }
                    else
                    {
                        sectionControl.ID = section.ID;
                    }



                    sectionControl.Visible = RenderSection;

                    div.Controls.Add(sectionControl);

                    this.SectionControls.Add(sectionControl);
                }
                else
                {
                    throw new ApplicationException("GetSectionControl() could not load usercontrol");
                }
            }
            catch (Exception ex)
            {
                string ErrorMessageFormat = "<span style='color:red'>ERROR - Could not load section {0} - {1} - {2}</span>";
                string ErrorMessages      = String.Format(ErrorMessageFormat, section.Name, section.Type, ex.Message);

                div.Controls.Add(new LiteralControl(ErrorMessages));
            }
        }
コード例 #3
0
        private void SetPageSection(string SectionID, string MemberType, string Member, string Value)
        {
            BaseSectionControl s = Page.FindSection(SectionID);

            if (s != null)
            {
                s.Update(SectionID, MemberType, Member, Value);
            }
            else
            {
                SetViaReflection(SectionID, Member, Value);
            }
        }
コード例 #4
0
ファイル: Common.cs プロジェクト: dolani/CodeTorch
        public static BaseSectionControl FindSection(BasePage page, Control container, string id)
        {
            BaseSectionControl retVal = null;

            ControlCollection controls = null;

            if (container == null)
            {
                controls = page.Controls;
            }
            else
            {
                controls = container.Controls;
            }


            foreach (Control c in controls)
            {
                if ((c.ID != null) && (c.ID.ToLower() == id.ToLower()))
                {
                    if (c is BaseSectionControl)
                    {
                        retVal = (BaseSectionControl)c;
                        return(retVal);
                    }
                }
                else
                {
                    if (c.HasControls())
                    {
                        Control child = FindControlRecursive(c, id);
                        if (child != null)
                        {
                            if (child is BaseSectionControl)
                            {
                                retVal = (BaseSectionControl)child;
                                return(retVal);
                            }
                        }
                    }
                }
            }

            return(retVal);
        }