示例#1
0
        /// <summary>
        /// 页面渲染之前
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPreRender(EventArgs e)
        {
            if (this.CurrentMode == ControlShowingMode.Normal)
            {
                if (this.BeforeNormalPreRender != null)
                {
                    this.BeforeNormalPreRender(this, e);
                }
            }

            base.OnPreRender(e);

            ViewState["ControlParams"] = ControlParams;
            RenderClientVariables();

            if (this.CurrentMode == ControlShowingMode.Dialog)
            {
                DialogContentAttribute contentAttr = AttributeHelper.GetCustomAttribute <DialogContentAttribute>(this.GetType());

                if (contentAttr != null)
                {
                    this.EnableViewState = contentAttr.EnableViewState;
                }
            }
        }
示例#2
0
        /// <summary>
        /// 加载对话框的模板
        /// </summary>
        /// <returns></returns>
        protected virtual Control LoadDialogTemplate()
        {
            DialogTemplateAttribute templateAttr = AttributeHelper.GetCustomAttribute <DialogTemplateAttribute>(this.GetType());

            string pageHtml = string.Empty;

            if (templateAttr != null && string.IsNullOrEmpty(templateAttr.ResourcePath) == false)
            {
                pageHtml = ResourceHelper.LoadStringFromResource(Assembly.GetExecutingAssembly(), templateAttr.ResourcePath);
            }
            else
            {
                Assembly assembly = Assembly.GetExecutingAssembly();

                if (templateAttr != null && string.IsNullOrEmpty(templateAttr.AssemblyName) == false)
                {
                    assembly = Assembly.Load(templateAttr.AssemblyName);
                }

                pageHtml = ResourceHelper.LoadStringFromResource(assembly,
                                                                 "MCS.Web.WebControls.Script.Resources.standardDialogControlTemplate.htm");
            }

            DialogContentAttribute contentAttr = AttributeHelper.GetCustomAttribute <DialogContentAttribute>(this.GetType());

            if (contentAttr != null && string.IsNullOrEmpty(contentAttr.ResourcePath) == false)
            {
                Assembly assembly = Assembly.GetExecutingAssembly();

                if (string.IsNullOrEmpty(contentAttr.AssemblyName) == false)
                {
                    assembly = Assembly.Load(contentAttr.AssemblyName);
                }

                LoadingDialogContentEventArgs eventArgs = new LoadingDialogContentEventArgs();

                OnLoadingDialogContent(this, eventArgs);

                string html = eventArgs.Content;

                if (html.IsNullOrEmpty())
                {
                    html = ResourceHelper.LoadStringFromResource(assembly, contentAttr.ResourcePath);
                }

                pageHtml = pageHtml.Replace("<!--dialogContent-->", html);
            }

            pageHtml = ReplaceDialogTemplateString(pageHtml);

            return(Page.ParseControl(pageHtml));
        }