public void Load_ControlEditor_TemplateDesignMode(System.Web.UI.Page myPage, string Page_ControlID) { Templates.MasterPageEditorMgr myMasterPageEditor = new Templates.MasterPageEditorMgr(); MasterPage_Lock_Control myMasterPage_Control = myMasterPageEditor.Get_MasterPage_Lock_Control(Page_ControlID); Modules.ModuleMgr myModuleMgr = new Modules.ModuleMgr(); Modules.Component myComponent = myModuleMgr.Get_Component(myMasterPage_Control.ComponentID); Modules.Component_Control myControl = myModuleMgr.Get_Control(myMasterPage_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 <MasterPage_Lock_Control_Property> Control_Properties = myMasterPageEditor.Get_MasterPage_Lock_Control_Properties(myMasterPage_Control.Page_ControlID); // Load Exist Control foreach (MasterPage_Lock_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, "TemplateDesignMode", null); // 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}", myMasterPage_Control.ComponentID)); } }
public void Add_MasterPage_Control_Properties_DesignMode(Control_Property[] Update_Properties) { foreach (Control_Property Update_Property in Update_Properties) { e2Data[] UpdateData = { new e2Data("Page_ControlID", Update_Property.Page_ControlID), new e2Data("Property_Name", Update_Property.Property_Name), new e2Data("Property_Value", Update_Property.Property_Value) }; Templates.MasterPageEditorMgr myMasterPageEditor = new Templates.MasterPageEditorMgr(); myMasterPageEditor.Add_MasterPage_Lock_Property(UpdateData); } }