Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="thisModule"></param>
        /// <param name="moduleContainer"></param>
        /// <returns></returns>
        public static ModuleMessage.ModuleMessageType LoadModuleControl(PortalModuleBase thisModule, PlaceHolder moduleContainer)
        {
            ModuleMessage.ModuleMessageType result = ModuleMessage.ModuleMessageType.RedError;
            try
            {
                Components.SettingsRepository _settingsCtrl = new Components.SettingsRepository(thisModule.ModuleContext.ModuleId, thisModule.ModuleContext.TabModuleId);

                if (!String.IsNullOrEmpty(_settingsCtrl.ModuleView))
                {
                    string modulePath = String.Format("{0}/{1}", thisModule.TemplateSourceDirectory, _settingsCtrl.ModuleView);
                    var    objControl = thisModule.LoadControl(modulePath) as PortalModuleBase;
                    if (objControl != null)
                    {
                        moduleContainer.Controls.Clear();
                        objControl.ModuleContext.Configuration = thisModule.ModuleContext.Configuration;
                        objControl.LocalResourceFile           = thisModule.LocalResourceFile.Replace("Dispatch", _settingsCtrl.ModuleView.Replace(".ascx", ""));
                        objControl.ID = System.IO.Path.GetFileNameWithoutExtension(modulePath);
                        moduleContainer.Controls.Add(objControl);
                        result = ModuleMessage.ModuleMessageType.GreenSuccess;
                    }
                }
                if (result != ModuleMessage.ModuleMessageType.GreenSuccess)
                {
                    result = ModuleMessage.ModuleMessageType.YellowWarning;
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                result = ModuleMessage.ModuleMessageType.RedError;
            }

            return(result);
        }
Ejemplo n.º 2
0
        protected ProviderControlBase LoadControl(PortalModuleBase parentControl, string controlPath, string controlName)
        {
            string controlValue = "";

            controlPath = VirtualPathUtility.AppendTrailingSlash(VirtualPathUtility.Combine(controlPath, _info.VirtualPath));
            for (int i = 0; i < _info.Controls.Length; i++)
            {
                if (_info.Controls[i].Name == controlName)
                {
                    controlValue = _info.Controls[i].Value;
                    break;
                }
            }
            controlPath = VirtualPathUtility.Combine(controlPath, controlValue);

            ProviderControlBase childControl = (ProviderControlBase)parentControl.LoadControl(controlPath);

            childControl.ParentControl = parentControl;

            return(childControl);
        }