Example #1
0
        public void Load_ControlEditor_PageAdvancedMode(System.Web.UI.Page myPage, string Page_ControlID)
        {
            PageMgr      myPageMgr      = new PageMgr();
            Page_Control myPage_Control = myPageMgr.Get_Page_Control(Page_ControlID);

            Modules.ModuleMgr         myModuleMgr = new Modules.ModuleMgr();
            Modules.Component         myComponent = myModuleMgr.Get_Component(myPage_Control.ComponentID);
            Modules.Component_Control myControl   = myModuleMgr.Get_Control(myPage_Control.ComponentID, Modules.Control_Type.Editor);

            if (myControl.Assembly_Name != null)
            {
                Assembly assembly = Assembly.Load(new AssemblyName(myControl.Assembly_Name));

                Type    _control_type = assembly.GetType(myControl.Class_Name);
                Control _control      = myPage.LoadControl(_control_type, null);

                List <Page_Control_Property> Control_Properties = myPageMgr.Get_Page_Control_Properties(myPage_Control.Page_ControlID);

                // Load Exist Control
                foreach (Page_Control_Property Control_Property in Control_Properties)
                {
                    PropertyInfo _Control_Property = _control_type.GetProperty(Control_Property.Property_Name);

                    switch (_Control_Property.PropertyType.FullName)
                    {
                    case "System.String":
                        _Control_Property.SetValue(_control, Control_Property.Property_Value, null);
                        break;

                    case "System.Int32":
                        _Control_Property.SetValue(_control, Convert.ToInt32(Control_Property.Property_Value), null);
                        break;

                    case "System.Boolean":
                        _Control_Property.SetValue(_control, Convert.ToBoolean(Control_Property.Property_Value), null);
                        break;

                    default:
                        _Control_Property.SetValue(_control, Control_Property.Property_Value, null);
                        break;
                    }
                }

                // Place PageControlID and EditMode
                PropertyInfo Page_ControlID_Property = _control_type.GetProperty("Page_ControlID");
                Page_ControlID_Property.SetValue(_control, Page_ControlID, null);

                PropertyInfo EditMode_Property = _control_type.GetProperty("EditMode");
                EditMode_Property.SetValue(_control, "PageAdvancedMode", null);

                // Create Events Failed
                //EventInfo _Control_Event = _control_type.GetEvent("FinishUpdate");
                //_Control_Event.

                // Create Editor
                PlaceHolder myPlaceHolder = (PlaceHolder)myPage.FindControl("PlaceHolder_Editor");
                myPlaceHolder.Controls.Add(_control);
            }
            else
            {
                throw new Exception(string.Format("Invalid PageControl Editor.Design Mode ComponentID: {0}", myPage_Control.ComponentID));
            }
        }