/// <summary>
        /// Returns the proper edit ascx Control. Uses the current Page to load the Control.
        /// If the user has no right a error control is returned
        /// </summary>
        /// <param name="p">The current Page</param>
        /// <returns>Edit ascx Control</returns>
        internal static Control GetEditControl(Page p)
        {
            PortalDefinition.Tab tab = PortalDefinition.GetCurrentTab();
            PortalDefinition.Module m = tab.GetModule(p.Request["ModuleRef"]);

            if(!UserManagement.HasEditRights(HttpContext.Current.User, m.roles))
            {
                // No rights, return a error Control
                Label l = new Label();
                l.CssClass = "Error";
                l.Text = "Access denied!";
                return l;
            }
            m.LoadModuleSettings();
            Module em = null;
            if(m.moduleSettings != null)
            {
                // Module Settings are present, use custom ascx Control
                em = (Module)p.LoadControl(Config.GetModuleVirtualPath(m.type) + m.moduleSettings.editCtrl);
            }
            else
            {
                // Use default ascx control (Edit[type].ascx)
                em = (Module)p.LoadControl(Config.GetModuleVirtualPath(m.type) + "Edit" + m.type + ".ascx");
            }

            // Initialize the control
            em.InitModule(
                tab.reference,
                m.reference,
                Config.GetModuleVirtualPath(m.type),
                true);

            return em;
        }
        public override Control CreateSearchControl(Page parent)
        {
            IReportParameterSearch ctrl = null;
            switch (this.TextType)
            {
                case ReportFilterTextType.String:
                    ctrl = (UcReportParameterSearchText)parent.LoadControl("~/Controls/ReportParameterSearch/UcReportParameterSearchText.ascx");
                    break;
                case ReportFilterTextType.Date:
                case ReportFilterTextType.DatePicker:
                    ctrl = (UcReportParameterSearchDate)parent.LoadControl("~/Controls/ReportParameterSearch/UcReportParameterSearchDate.ascx");
                    break;
                case ReportFilterTextType.Integer:
                case ReportFilterTextType.Decimal:
                    UcReportParameterSearchNumeric numeric = (UcReportParameterSearchNumeric)parent.LoadControl("~/Controls/ReportParameterSearch/UcReportParameterSearchNumeric.ascx");
                    if (this.TextType == ReportFilterTextType.Integer)
                    {
                        numeric.Control.NumberFormat.AllowRounding = false;
                        numeric.Control.NumberFormat.DecimalDigits = 0;
                        numeric.Control.NumberFormat.GroupSizes = 9;
                    }
                    ctrl = numeric;
                    break;
                default:
                    throw new NotSupportedException(this.TextType.ToString());
            }
            this.SetBaseInfo(ctrl);

            Control ret = (Control)ctrl;
            ret.ID = "txt_" + "Rep" + "_" + this.ParameterName.Replace("@", String.Empty).Replace(":", String.Empty);

            return ret;
        }
Exemple #3
0
        public static Control Load(WidgetDefinition widget, Page hostingPage, bool loadInDesignMode)
        {
            Require.NotNull(widget, "widget");
            Require.NotNull(hostingPage, "hostingPage");

            Control control = null;

            if (loadInDesignMode)
            {
                if (File.Exists(HostingEnvironment.MapPath(widget.DesignerVirtualPath)))
                {
                    control = hostingPage.LoadControl(widget.DesignerVirtualPath);
                }
                else
                {
                    control = new DefaultWidgetControl();
                }
            }
            else
            {
                control = hostingPage.LoadControl(widget.WidgetControlVirtualPath);
            }

            return control;
        }
Exemple #4
0
        private static ContentView CreateFromActualPath(SNC.Content content, System.Web.UI.Page aspNetPage, ViewMode viewMode, string viewPath)
        {
            if (content == null)
            {
                throw new ArgumentNullException("content");
            }
            if (aspNetPage == null)
            {
                throw new ArgumentNullException("aspNetPage");
            }
            if (viewPath == null)
            {
                throw new ArgumentNullException("viewPath");
            }
            if (viewPath.Length == 0)
            {
                throw new ArgumentOutOfRangeException("viewPath", "Parameter 'viewPath' cannot be empty");
            }
            if (viewMode == ViewMode.None)
            {
                throw new ArgumentOutOfRangeException("viewMode", "Parameter 'viewMode' cannot be ViewMode.None");
            }

            string path = String.Concat("~", viewPath);

            ContentView view = GetContentViewFromCache(path);

            // if not in request cache
            if (view == null)
            {
                var addToCache = false;
                try
                {
                    view       = aspNetPage.LoadControl(path) as ContentView;
                    addToCache = true;
                }
                catch (Exception e) //logged
                {
                    Logger.WriteException(e);
                    var errorContentViewPath         = RepositoryPath.Combine(Repository.ContentViewFolderName, "Error.ascx");
                    var resolvedErrorContentViewPath = SkinManager.Resolve(errorContentViewPath);
                    path = String.Concat("~", resolvedErrorContentViewPath);
                    view = aspNetPage.LoadControl(path) as ContentView;
                    view.ContentException = e;
                }
                if (view == null)
                {
                    throw new ApplicationException(string.Format("ContentView instantiation via LoadControl for path '{0}' failed.", path));
                }
                if (addToCache)
                {
                    AddContentViewToCache(path, view);
                }
            }

            view.Initialize(content, viewMode);
            return(view);
        }
        private static BaseEFormControl GetEformComponent(System.Web.UI.Page page, string disease, XElement node)
        {
            string controlName                = "";
            string controlTitle               = "";
            string overrideLookupCodes        = "";
            string associatedEformName        = "";
            string associatedEformSectionName = "";

            controlName = node.Attribute("controlName").Value + ".ascx";

            if (node.Attribute("displayName") != null)
            {
                controlTitle = node.Attribute("displayName").Value;
            }

            if (node.Attribute("overrideLookupCodes") != null)
            {
                overrideLookupCodes = node.Attribute("overrideLookupCodes").Value;
            }

            if (node.Attribute("associatedEformName") != null)
            {
                associatedEformName = node.Attribute("associatedEformName").Value;
            }

            if (node.Attribute("associatedEformSectionName") != null)
            {
                associatedEformSectionName = node.Attribute("associatedEformSectionName").Value;
            }

            //System.Web.UI.UserControl eFormControl;
            Caisis.UI.Core.Classes.BaseEFormControl eFormControl;

            // check the current disease view first for the .ascx file
            if (System.IO.File.Exists("~/Modules/" + disease + "/Eforms/" + controlName))
            {
                eFormControl = page.LoadControl("~/Modules/" + disease + "/Eforms/" + controlName) as Caisis.UI.Core.Classes.BaseEFormControl;
            }
            else // check the other modules for the .ascx file
            {
                string folder = Caisis.UI.Core.Classes.XmlUtil.GetParentModuleDirectory(controlName, "EForms");
                eFormControl = page.LoadControl("~/Modules/" + folder + "/Eforms/" + controlName) as Caisis.UI.Core.Classes.BaseEFormControl;
            }
            if (eFormControl != null)
            {
                // set the control properties
                eFormControl.Title                      = controlTitle;
                eFormControl.LookupCodes                = overrideLookupCodes;
                eFormControl.AssociatedEformName        = associatedEformName;
                eFormControl.AssociatedEformSectionName = associatedEformSectionName;
            }

            return(eFormControl);
        }
Exemple #6
0
 /// <summary>
 /// Gets the activity primitive.
 /// </summary>
 /// <param name="activity">The activity.</param>
 /// <param name="pageInstanse">The page instanse.</param>
 /// <returns></returns>
 public static Control GetActivityPrimitive(Activity activity, Page pageInstanse)
 {
     //ToDo: get additional info from activity
     if (activity is CompositeActivity && ((CompositeActivity)activity).Activities.Count > 0)
     {
         return pageInstanse.LoadControl("~/Modules/Primitives/CompositeActivity.ascx");
     }
     else
     {
         return pageInstanse.LoadControl("~/Modules/Primitives/SimpleActivity.ascx");
     }
 }
        protected Control LoadControl(string templateName, Page page, IProcessResponse response, Domain domain)
        {
            string templatePath = string.Format("~/{0}/{1}", RenderingSection.Current.Path, templateName);
            WebFormsControl control = null;

            try
            {
                control = page.LoadControl(templatePath) as WebFormsControl;
            }
            catch (Exception ex)
            {
            #if DEBUG
                throw ex;
            #endif
            }

            if (control != null)
            {
                control.URI = URI;
                control.Response = response;
                control.Domain = domain;
                control.Renderer = this;
            }
            return control;
        }
        /// <summary>
        /// The GetModuleSettings Method returns a hashtable of
        ///   custom module specific settings from the database. This method is
        ///   used by some user control modules to access misc settings.
        /// </summary>
        /// <param name="moduleId">
        /// The module ID.
        /// </param>
        /// <param name="userId">
        /// The user ID.
        /// </param>
        /// <param name="page">
        /// The page for settings.
        /// </param>
        /// <returns>
        /// The hash table.
        /// </returns>
        /// <remarks>
        /// </remarks>
        public static Hashtable GetModuleUserSettings(int moduleId, Guid userId, Page page)
        {
            var controlPath = Path.ApplicationRoot + "/";

            using (var dr = GetModuleDefinitionByID(moduleId))
            {
                if (dr.Read())
                {
                    controlPath += dr[StringsDesktopSrc].ToString();
                }
            }

            PortalModuleControlCustom portalModule;
            Hashtable setting;
            try
            {
                portalModule = (PortalModuleControlCustom)page.LoadControl(controlPath);
                setting = GetModuleUserSettings(
                    moduleId, PortalSettings.CurrentUser.Identity.ProviderUserKey, portalModule.CustomizedUserSettings);
            }
            catch (Exception ex)
            {
                // Appleseed.Framework.Configuration.ErrorHandler.HandleException("There was a problem loading: '" + ControlPath + "'", ex);
                // throw;
                throw new AppleseedException(
                    LogLevel.Fatal, string.Format("There was a problem loading: '{0}'", controlPath), ex);
            }

            return setting;
        }
        public string ExecutePrayerTimes(string xslID)
        {

            try
            {
                int _xslID = 0;
                int.TryParse(xslID, out _xslID);

                // Create a new Page and add the control to it.
                Page page = new Page();
                Control ucPrayerTimes = page.LoadControl("~/Services/PrayerTimes/PrayerTimes_UC.ascx");
                ucPrayerTimes.ID = "PrayerTimes_UC.ascx" + xslID;

                page.Controls.Add(ucPrayerTimes);
                ((TG.ExpressCMS.UI.Custums.PrayerTimes_UC)ucPrayerTimes).GetDailyXmlFile(_xslID);

                // Render the page and capture the resulting HTML.
                StringWriter writer = new StringWriter();
                HttpContext.Current.Server.Execute(page, writer, false);

                // Return that HTML, as a string.
                return writer.ToString();
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }
        public static string RenderControl(string path, string propertyName, object propertyValue)
        {
            Page pageHolder = new Page();
            pageHolder.EnableEventValidation = false;

            UserControl viewControl =
                (UserControl)pageHolder.LoadControl(path);

            if (propertyValue != null)
            {
                Type viewControlType = viewControl.GetType();
                PropertyInfo property =
                    viewControlType.GetProperty(propertyName);

                if (property != null)
                {
                    property.SetValue(viewControl, propertyValue, null);
                }
                else
                {
                    throw new Exception(string.Format(
                        "UserControl: {0} does not have a public {1} property.", path, propertyName));
                }
            }

            HtmlForm _form = new HtmlForm();
            pageHolder.Controls.Add(_form);
            _form.Controls.Add(viewControl);

            StringWriter output = new StringWriter();
            HttpContext.Current.Server.Execute(pageHolder, output, false);                          
            return output.ToString();
        }
        public static string RenderView(string path, bool populateFromQueryString, out IServiceMetadata metadata, out IPagingDataProvider pagingData)
        {
            Page page = new Page();
            UserControl ctrl = (UserControl)page.LoadControl(path);

            return RenderControlInternal(page, ctrl, populateFromQueryString, out metadata, out pagingData);
        }
        public string GetHtmlEventItems(string Year, string Month, string Day, string CategoryID)
        {
            try
            {
                DateTime dateTime = new DateTime(Convert.ToInt32(Year), Convert.ToInt32(Month), Convert.ToInt32(Day));
                int catID = 0;
                int.TryParse(CategoryID, out catID);

                // Create a new Page and add the control to it.
                Page page = new Page();
                Control ucEventViewerService = page.LoadControl("~/Services/Event/GUI/EventViewerService_UC.ascx");
                ucEventViewerService.ID = "EventViewerService_UCCat" + CategoryID;

                page.Controls.Add(ucEventViewerService);
                ((TG.ExpressCMS.UI.Services.EventViewerService_UC)ucEventViewerService).LoadEvents(dateTime, catID);

                // Render the page and capture the resulting HTML.
                StringWriter writer = new StringWriter();
                HttpContext.Current.Server.Execute(page, writer, false);

                // Return that HTML, as a string.
                return writer.ToString();
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }
        public override Control CreateSearchControl(Page parent)
        {
            UcReportParameterSearchFK ctrl = (UcReportParameterSearchFK)parent.LoadControl("~/Controls/ReportParameterSearch/UcReportParameterSearchFK.ascx");

            this.SetBaseInfo(ctrl);

            ctrl.ID = "cfk_" + "Rep" + "_" + this.ParameterName.Replace("@", String.Empty).Replace(":", String.Empty);

            ctrl.DataTableField = this.DataTableField;
            ctrl.DataTextField = this.DataTextField;
            ctrl.DataValueField = this.DataValueField;
            ctrl.FilterExpression = this.FilterExpression;
            ctrl.SortExpression = this.SortExpression;

            //extended
            ctrl.ComboBox.LoadItemsOnLoad = false;

            using (IDbAccess reportAccess = base.Parent.CreateDbAccess())
            {
                ctrl.ComboBox.Factory = DataUtils.CreateFactory(reportAccess);
                ctrl.ComboBox.LoadItems();
            }

            return ctrl;
        }
Exemple #14
0
        public static string RenderTemplateHtml(string virtualPath)
        {
            Page pageHolder = new Page();
            UserControl viewControl = (UserControl)pageHolder.LoadControl(virtualPath);

            // Insert placeholder div's into the placholder.
            foreach (KeyValuePair<string, PlaceHolder> placeHolder in ExtractPlaceholdersFromControl(viewControl))
            {
                string placeHolderDiv = String.Format("<div id=\"{0}\" class=\"{1}\"><div class=\"placeholdertitle\">{2}</div><ul class=\"sectionlist\"></ul></div>"
                    , "plh-" + placeHolder.Key, "contentplaceholder", placeHolder.Key);
                Literal placeHolderContentControl = new Literal();
                placeHolderContentControl.Text = placeHolderDiv;
                placeHolder.Value.Controls.Add(placeHolderContentControl);
            }

            // Only render inner contents of the form
            HtmlForm theForm = FindForm(viewControl);
            while (theForm.Controls.Count > 0)
            {
                pageHolder.Controls.Add(theForm.Controls[0]);
            }
            StringWriter output = new StringWriter();
            HttpContext.Current.Server.Execute(pageHolder, output, false);

            return output.ToString();
        }
        public static string RenderControl(string path, object data)
        {
            Page pageHolder = new Page();
            pageHolder.EnableEventValidation = false;

            UserControl viewControl = (UserControl)pageHolder.LoadControl(path);
            if (data != null)
            {
                Type viewControlType = viewControl.GetType();
                FieldInfo field = viewControlType.GetField("Data");

                if (field != null)
                {
                    field.SetValue(viewControl, data);
                }
                else
                {
                    throw new Exception("View file: " + path + " does not have a public Data property");
                }
            }
            
            HtmlForm _form = new HtmlForm();
            pageHolder.Controls.Add(_form);
            _form.Controls.Add(viewControl);

            StringWriter output = new StringWriter();
            HttpContext.Current.Server.Execute(pageHolder, output, false);           
            return output.ToString();
        }
Exemple #16
0
        /// <summary>
        /// 用指定的用户控件以及视图数据呈现结果,最后返回生成的HTML代码。
        /// 用户控件应从MyUserControlView&lt;T&gt;继承
        /// </summary>
        /// <param name="ucVirtualPath">用户控件的虚拟路径</param>
        /// <param name="model">视图数据</param>
        /// <returns>生成的HTML代码</returns>
        public static string Render(string ucVirtualPath, object model)
        {
            if (string.IsNullOrEmpty(ucVirtualPath))
                throw new ArgumentNullException("ucVirtualPath");

            Page page = new Page();
            Control ctl = page.LoadControl(ucVirtualPath);
            if (ctl == null)
                throw new InvalidOperationException(
                    string.Format("指定的用户控件 {0} 没有找到。", ucVirtualPath));

            if (model != null)
            {
                MyBaseUserControl myctl = ctl as MyBaseUserControl;
                if (myctl != null)
                    myctl.SetModel(model);
            }

            // 将用户控件放在Page容器中。
            page.Controls.Add(ctl);

            StringWriter output = new StringWriter();
            HtmlTextWriter write = new HtmlTextWriter(output, string.Empty);
            page.RenderControl(write);

            // 用下面的方法也可以的。
            //HttpContext.Current.Server.Execute(page, output, false);

            return output.ToString();
        }
        public static string RenderView(string path, object data, string fieldName)
        {
            Page pageHolder = new Page();
            UserControl viewControl = (UserControl) pageHolder.LoadControl(path);

            if (data != null)
            {
                Type viewControlType = viewControl.GetType();
                FieldInfo field = viewControlType.GetField(fieldName);

                if (field != null)
                {
                    field.SetValue(viewControl, data);
                }
                else
                {
                    throw new Exception("View file: " + path + " does not have a public Data property");
                }
            }

            pageHolder.Controls.Add(viewControl);

            StringWriter output = new StringWriter();

            try
            {
                HttpContext.Current.Server.Execute(pageHolder, output, false);
            }
            catch
            {
                // TODO :: implement error logging here
                //Website_Helpers.sendError(path + " || " + ex.Message);
            }
            return output.ToString();
        }
Exemple #18
0
 public static System.Web.UI.Control LoadPageControl(System.Web.UI.Control placeholder, string pageName, bool developmentMode)
 {
     try
     {
         System.Web.UI.Page page     = placeholder.Page;
         string             basePath = "~";
         if (!(developmentMode))
         {
             basePath = "~/DesktopModules/MyCompany";
         }
         string controlPath      = String.Format("{0}/Pages/{1}.ascx", basePath, pageName);
         System.Web.UI.Control c = page.LoadControl(controlPath);
         if (c != null)
         {
             placeholder.Controls.Clear();
             placeholder.Controls.Add(new LiteralControl("<table style=\"width:100%\" id=\"PageBody\" class=\"Hosted\"><tr><td valign=\"top\" id=\"P" +
                                                         "ageContent\">"));
             placeholder.Controls.Add(c);
             placeholder.Controls.Add(new LiteralControl("</td></tr></table>"));
             return(c);
         }
     }
     catch (Exception)
     {
     }
     return(null);
 }
        public Dictionary<string, string> UpdateImage(int mediaId, string style, string linkTarget)
		{
            legacyAjaxCalls.Authorize();


			//load the control with the specified properties and render the output as a string and return it
			Page page = new Page();
			string path = Umbraco.Core.IO.IOHelper.ResolveUrl(Umbraco.Core.IO.SystemDirectories.Umbraco) + "/controls/Images/ImageViewer.ascx";
			
			ImageViewer imageViewer = page.LoadControl(path) as ImageViewer;
			imageViewer.MediaId = mediaId;
            ImageViewer.Style _style = (ImageViewer.Style)Enum.Parse(typeof(ImageViewer.Style), style);
            imageViewer.ViewerStyle = _style;
			imageViewer.LinkTarget = linkTarget;

			//this adds only the anchor with image to be rendered, not the whole control!
			page.Controls.Add(imageViewer);
			
			imageViewer.DataBind();

			StringWriter sw = new StringWriter();
			HttpContext.Current.Server.Execute(page, sw, false);

            Dictionary<string, string> rVal = new Dictionary<string, string>();
            rVal.Add("html", sw.ToString());
            rVal.Add("mediaId", imageViewer.MediaId.ToString());
            rVal.Add("width", imageViewer.FileWidth.ToString());
            rVal.Add("height", imageViewer.FileHeight.ToString());
            rVal.Add("url", imageViewer.MediaItemPath);
            rVal.Add("alt", imageViewer.AltText);

            return rVal;
		}
Exemple #20
0
        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));
            }
        }
Exemple #21
0
 public void InvokeFunc(System.Web.UI.Page p)
 {
     string[] ascxVPath = { "~/Manage/I/ASCX/NodeTree.ascx", "~/Manage/I/ASCX/UserGuide.ascx" };
     for (int i = 0; i < ascxVPath.Length; i++)
     {
         p.LoadControl(ascxVPath[i]);
     }
 }
 public static void SaveChartImage(string controlLocation, IEnumerable data, Stream stream)
 {
     using (var page = new Page())
     using (var control = (IReportControl)page.LoadControl("~/Reports/" + controlLocation))
     {
         control.DataSource = data;
         control.DataBind();
         control.SaveChartImage(stream);
     }
 }
Exemple #23
0
 public static string UserControlToString(string controlPath)
 {
     StringBuilder sb = new StringBuilder();
     StringWriter stWriter = new StringWriter(sb);
     HtmlTextWriter htmlWriter = new HtmlTextWriter(stWriter);
     Page page = new Page();
     SignForm signForm = (SignForm) page.LoadControl(controlPath);
     signForm.RenderControl(htmlWriter);
     return sb.ToString();
 }
Exemple #24
0
 private string RenderView(DataTable dt)
 {
     StringWriter output = new StringWriter();
     Page page = new Page();
     orderli li = (orderli)page.LoadControl("~/Controls/orderli.ascx");
     li.DataSource = dt;
     page.Controls.Add(li);
     HttpContext.Current.Server.Execute(page, output, false);
     return output.ToString();
 }
Exemple #25
0
        protected Control InitializeUserControl(string path)
        {
            Control c = null;

            System.Web.UI.Page page = GetPage();
            if (page != null)
            {
                c = page.LoadControl(path);
            }
            return(c);
        }
 private string RenderView(DataTable dt)
 {
     StringWriter output = new StringWriter();
     Page page = new Page();
     feedbackli li = (feedbackli)page.LoadControl("~/Controls/feedbackli.ascx");
     li.DataSource = dt;
     li.i = ((Int64) PIndex - 1) * PSize + 1;
     page.Controls.Add(li);
     HttpContext.Current.Server.Execute(page, output, false);
     return output.ToString();
 }
        public override Control CreateSearchControl(Page parent)
        {
            UcReportParameterSearchList ctrl = (UcReportParameterSearchList)parent.LoadControl("~/Controls/ReportParameterSearch/UcReportParameterSearchList.ascx");
            
            this.SetBaseInfo(ctrl);

            ctrl.ID = "cbx_" + "Rep" + "_" + this.ParameterName.Replace("@", String.Empty).Replace(":", String.Empty);

            ctrl.Expression = this.Expression;

            return ctrl;
        }
 /// <summary>
 /// 加载用户控件
 /// </summary>
 /// <param name="pathName"></param>
 /// <returns></returns>
 public string Include(string pathName)
 {
     try {
         System.Web.UI.Page page = new System.Web.UI.Page();
         UserControl        ctl  = (UserControl)page.LoadControl(pathName);
         page.Controls.Add(ctl);
         StringWriter writer = new StringWriter();
         HttpContext.Current.Server.Execute(page, writer, true);
         return(writer.ToString());
     }
     catch (Exception ex) { return(pathName + "加载失败!" + ex.Message + ex.InnerException); }
 }
        public override Control CreateSearchControl(Page parent)
        {
            UcFieldSearchCombo ctrl = (UcFieldSearchCombo)parent.LoadControl("~/Controls/FieldSearch/UcFieldSearchCombo.ascx");

            this.SetBaseInfo(ctrl);

            ctrl.ID = "cbx_" + ctrl.DataSourceName + "_" + this.ColumnName;
            
            ctrl.Expression = this.Expression;

            return ctrl;
        }
 public string GetControlHtml(string controlLocation)
 {
     Page page = new Page();
     UserControl userControl = (UserControl)page.LoadControl(controlLocation);
     userControl.EnableViewState = false;
     HtmlForm form = new HtmlForm();
     form.Controls.Add(userControl);
     page.Controls.Add(form);
     StringWriter textWriter = new StringWriter();
     HttpContext.Current.Server.Execute(page, textWriter, false);
     return CleanHtml(textWriter.ToString());
 }
Exemple #31
0
 /// <summary>
 /// ��ȡ�û��ؼ�
 /// </summary>
 /// <param name="key">�ؼ���</param>
 /// <returns>�����û��ؼ�</returns>
 public Control GetControl(string key)
 {
     Page page = new Page();
     Control control = new Control();
     if (PluginItems.ContainsKey(key))
     {
         PluginItem pluginItem = PluginItems[key];
         control = page.LoadControl(pluginItem.ManagePath);
         control.ID = pluginItem.Key;
     }
     return control;
 }
Exemple #32
0
 /// <summary>
 /// 根据路径执行ascx控件
 /// </summary>
 /// <param name="controlPath">控件的虚拟路径</param>
 /// <returns></returns>
 public static string ExecutorAscx(string controlPath,string requestQueryString)
 {
     MasterPage = new Page();
     StringWriter outStream = new StringWriter();
     Control ctl = MasterPage.LoadControl(controlPath);
     if (AjaxCallChecker.isAllowExecAscx(HttpContext.Current, ctl, AscxInterceptor))
     {
         MasterPage.Controls.Add(ctl);
         HttpContext.Current.Server.Execute(MasterPage, outStream, true);
         return outStream.ToString();
     }
     return "Deny!";
 }
        private string LoadCustomControl(string controlName)
        {
            Page page = new Page();
            UserControl userControl = (UserControl)page.LoadControl(controlName);
            userControl.EnableViewState = false;
            System.Web.UI.HtmlControls.HtmlForm form = new System.Web.UI.HtmlControls.HtmlForm();
            form.Controls.Add(userControl);
            page.Controls.Add(form);

            System.IO.StringWriter textWriter = new System.IO.StringWriter();
            HttpContext.Current.Server.Execute(page, textWriter, false);
            return textWriter.ToString();
        }
Exemple #34
0
        public static PropertyGroup CreatePropertyGroupFromModule(Page page, Lifelike.Data.Entities.Module m)
        {
            var propGroup = new PropertyGroup();
            var lstCtlProps = new List<Property>();

            Control c = page.LoadControl("~/" + m.Path);

            propGroup.Name = m.Name;
            propGroup.Type = c.GetType().ToString();

            var controlProps = Reflection.GetAllPropertiesByType<Field>(c);
            propGroup.Properties = CreatePropertyList(controlProps, propGroup.Properties);
            return propGroup;
        }
        public string GetHeader()
        {
            // Create a new Page and add the control to it.
            Page page = new Page();
            UserControl ctl =
              (UserControl)page.LoadControl("~/Components/Header.ascx");
            page.Controls.Add(ctl);

            // Render the page and capture the resulting HTML.
            StringWriter writer = new StringWriter();
            HttpContext.Current.Server.Execute(page, writer, false);

            // Return that HTML, as a string.
            return writer.ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            file_message.Visible = false;
            folder_message.Visible = false;
            upload.Click += new EventHandler(upload_Click);
            createFolder.Click += new EventHandler(createFolder_Click);

            // Der Pfad wird im QueryString angegeben Default.aspx?c=files&p=test/bla/root/info.txt
            string path = Page.Request.QueryString["p"];
            if (!string.IsNullOrEmpty(path))
            {
                if (Page.Request.QueryString["f"].ToLower().Equals("true"))
                {
                    // TODO

                    Page pageHolder = new Page();
                    UserControl viewControl = (UserControl)pageHolder.LoadControl("~/Admin/UserControls/files_detail.ascx");

                    Type viewControlType = viewControl.GetType();
                    FieldInfo field = viewControlType.GetField("Data");
                    field.SetValue(viewControl, DataIO.loadFilesandFolders().Element("root"));

                    filesPlaceHolder.Controls.Add(viewControl);
                }
                else
                {
                    Page pageHolder = new Page();
                    UserControl viewControl = (UserControl)pageHolder.LoadControl("~/Admin/UserControls/files_directory.ascx");

                    Type viewControlType = viewControl.GetType();
                    FieldInfo field = viewControlType.GetField("Data");
                    field.SetValue(viewControl, DataIO.loadFilesandFolders().Element("root"));

                    filesPlaceHolder.Controls.Add(viewControl);
                }
            }
            else // Hier wird das Root Verzeichnis angezeigt
            {
                Page pageHolder = new Page();
                UserControl viewControl = (UserControl)pageHolder.LoadControl("~/Admin/UserControls/files_directory.ascx");

                Type viewControlType = viewControl.GetType();
                FieldInfo field = viewControlType.GetField("Data");
                field.SetValue(viewControl, DataIO.loadFilesandFolders().Element("root"));

                filesPlaceHolder.Controls.Add(viewControl);
            }
        }
        public static new ASearchItem loadInto(Page page, ASearchItemDto dto)
        {
            SearchItem_Between searchItem = page.LoadControl(SearchItem_Between.VirtualUrl) as SearchItem_Between;
            searchItem.Dto = dto;

            ListItem[] temp = new ListItem[3];
            temp[0] = new ListItem(Track.Property.Bpm.ToString(), ((int)Track.Property.Bpm).ToString());
            temp[1] = new ListItem(Track.Property.Laenge.ToString(), ((int)Track.Property.Laenge).ToString());
            temp[2] = new ListItem(Track.Property.Year.ToString(), ((int)Track.Property.Year).ToString());
            searchItem.ddlSearchCategory.Items.AddRange(temp);
            searchItem.ddlSearchCategory.SelectedIndex =
                searchItem.ddlSearchCategory.Items.IndexOf(searchItem.ddlSearchCategory.Items.FindByValue(((int)dto.TrackProperty).ToString()));
            searchItem.tbSearchPhrase2.Text = dto.SearchPhrase[1];

            return searchItem;
        }
Exemple #38
0
        public static UserControl LoadControl <Page>(string userControlPath, string id) where Page : System.Web.UI.Page, ISelfRenderingPage, new()
        {
            System.Web.UI.Page pageHolder = (System.Web.UI.Page) new Page();

            ResourceManager rm = new ResourceManager();

            rm.RenderScripts = ResourceLocationType.None;
            rm.RenderStyles  = ResourceLocationType.None;
            rm.IDMode        = IDMode.Explicit;
            pageHolder.Controls.Add(rm);

            id = id ?? "ID_" + Guid.NewGuid().ToString().Replace("-", "");
            System.Web.UI.Control uc = pageHolder.LoadControl(userControlPath);
            uc.ID = id + "_UC";

            return((UserControl)uc);
        }
Exemple #39
0
        public void Load_ControlPanel(System.Web.UI.Page myPage, PlaceHolder myPlaceHolder, string ControlID)
        {
            Modules.ModuleMgr myModuleMgr = new Modules.ModuleMgr();

            Modules.Component_Control myControl = myModuleMgr.Get_Control(ControlID);

            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);

                // Create Control
                //PlaceHolder myPlaceHolder = (PlaceHolder)myPage.FindControl(PlaceHolder_ID);
                myPlaceHolder.Controls.Add(_control);
            }
        }
        public static string RenderControlWithPostBack(string virtualPath)
        {
            System.Web.UI.Page page = new System.Web.UI.Page();
            page.EnableViewState       = false;
            page.EnableEventValidation = false;

            Control      control = page.LoadControl(virtualPath);
            StringWriter tw      = new StringWriter();

            HtmlForm form = new HtmlForm();

            form.ID = "__t";
            page.Controls.Add(form);
            form.Controls.Add(control);

            HttpContext.Current.Server.Execute(page, tw, true);

            return(tw.ToString());
        }
Exemple #41
0
        public void Load_ControlPanel(System.Web.UI.Page myPage, string PlaceHolder_ID, string ControlID, e2Data[] MyProperties)
        {
            Modules.ModuleMgr myModuleMgr = new Modules.ModuleMgr();

            Modules.Component_Control myControl = myModuleMgr.Get_Control(ControlID);

            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);

                // Load Exist Control
                foreach (e2Data myProperty in MyProperties)
                {
                    PropertyInfo _Control_Property = _control_type.GetProperty(myProperty.FieldName);

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

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

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

                    default:
                        _Control_Property.SetValue(_control, myProperty.FieldValue, null);
                        break;
                    }
                }

                // Create Control
                PlaceHolder myPlaceHolder = (PlaceHolder)myPage.FindControl(PlaceHolder_ID);
                myPlaceHolder.Controls.Add(_control);
            }
        }
Exemple #42
0
        protected override void Render(HtmlTextWriter output)
        {
            var page     = new System.Web.UI.Page();
            var xmltable = (XMLViewer)page.LoadControl("/XMLViewer.ascx");

            xmltable.Visible = true;
            xmltable.ID      = "XMLViewerID";
            xmltable.xmlpath = obj.Value;
            page.Controls.Add(xmltable);
            string htmlstring = string.Empty;

            using (var sw = new StringWriter())
            {
                System.Web.HttpContext.Current.Server.Execute(page, sw, false);
                htmlstring = sw.ToString();
            }

            output.Write(htmlstring);
            output.Flush();
            base.Render(output);
        }
Exemple #43
0
        /// <summary>
        /// 获取Web用户控件中的内容
        /// </summary>
        /// <typeparam name="T">控件所基于的基础网页类型,该类必需是由<see cref="System.Web.UI.Page"/>继承而来</typeparam>
        /// <param name="virtualPath">虚拟地址</param>
        /// <param name="format">格式化串</param>
        public static string GetUserControlString <T>(string virtualPath, params object[] format)
        {
            if (format.Length > 0)
            {
                virtualPath = string.Format(virtualPath, format);
            }

            System.Web.UI.Page p = Activator.CreateInstance <T>() as Page;
            p.LoadControl(virtualPath);
            StringWriter output = new StringWriter();

            HttpContext.Current.Server.Execute(p, output, false);
            return(output.ToString());

            //System.Web.UI.HtmlTextWriter tw = new HtmlTextWriter(new System.IO.StringWriter());
            //p.Controls.Add(((System.Web.UI.Control)System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(System.Web.UI.Control))));
            //p.ProcessRequest(HttpContext.Current);
            //p.RenderControl(tw);
            //System.IO.StringWriter sw = (System.IO.StringWriter)tw.InnerWriter;
            //return sw.GetStringBuilder().ToString();
        }
    /// <summary>
    /// Returns the HTML markup for a user control which will be created by it's virtual path and name.
    /// </summary>
    public static string RenderUserControl(this HtmlHelper helper, string controlVirtualPath, IEnumerable <KeyValuePair <string, object> > properties)
    {
        try
        {
            System.Web.UI.Page page = HttpContext.Current.Handler as System.Web.UI.Page;
            if (page != null)
            {
                Control control = page.LoadControl(controlVirtualPath);
                return(RenderControl(helper, control, properties));
            }
            else
            {
                Utils.Log(string.Format("Page is null when trying to render control: {0}", controlVirtualPath));
            }
        }
        catch (Exception ex)
        {
            Utils.Log(string.Format("Unable to load control: {0}", controlVirtualPath), ex);
        }

        return(HttpUtility.HtmlEncode(string.Format("ERROR - UNABLE TO LOAD CONTROL : {0}", controlVirtualPath)));
    }
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="Page"></typeparam>
        /// <param name="userControlPath"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static UserControl LoadControl <Page>(string userControlPath, string id) where Page : System.Web.UI.Page, ISelfRenderingPage, new()
        {
            System.Web.UI.Page pageHolder = (System.Web.UI.Page) new Page();

            ResourceManager rm = new ResourceManager(true);

            rm.RenderScripts = ResourceLocationType.None;
            rm.RenderStyles  = ResourceLocationType.None;
            rm.IDMode        = IDMode.Explicit;
            pageHolder.Controls.Add(rm);

            if (!userControlPath.StartsWith("~") && !userControlPath.StartsWith("/") && HttpContext.Current != null && HttpContext.Current.CurrentHandler is System.Web.UI.Page)
            {
                string dir = System.IO.Path.GetDirectoryName(HttpContext.Current.Request.CurrentExecutionFilePath).Replace("\\", "/");
                userControlPath = dir + "/" + userControlPath;
            }

            id = id ?? BaseControl.GenerateID();
            System.Web.UI.Control uc = pageHolder.LoadControl(userControlPath);
            uc.ID = id;

            return((UserControl)uc);
        }
Exemple #46
0
 /// <summary>
 /// 加载用户控件
 /// </summary>
 /// <param name="pathName"></param>
 /// <returns></returns>
 public string Include(string pathName)
 {
     try {
         /*
          * public static string RangerUsControl(string controlName)
          * {
          * StringBuilder build = new StringBuilder();
          * HtmlTextWriter htmlWriter = new HtmlTextWriter(new StringWriter(build));
          * UserControl uc = new UserControl();
          * Control ctrl=uc.LoadControl(controlName+".ascx");//加载用户定义控件
          *
          * TextBox txtBox1 = ctrl.FindControl("TextBox1") as TextBox;//获得id为“TextBox1”的控件
          * txtBox1.Text = "测试"; //给控件初始化
          * string result;
          * try
          * {
          * ctrl.RenderControl(htmlWriter);
          * }
          * catch { }
          * finally
          * {
          * htmlWriter.Flush();
          * result=build.ToString();
          * }
          *
          * return result;//返回控件的HTML代码
          * }
          */
         System.Web.UI.Page page = new System.Web.UI.Page();
         UserControl        ctl  = (UserControl)page.LoadControl(pathName);
         page.Controls.Add(ctl);
         StringWriter writer = new StringWriter();
         HttpContext.Current.Server.Execute(page, writer, true);
         return(writer.ToString());
     }
     catch (Exception ex) { return(pathName + "加载失败!" + ex.Message + ex.InnerException); }
 }
        /// <summary>
        /// This method is intended to be called once during FirstRequestInitialization
        /// right before LoadExtension() which is another time consuming routine.
        /// By preloading the widgets asyncronously in this method, this time consuming
        /// work is done in a manner that reduces the time to load the first page.
        /// </summary>
        /// <param name="zoneName">Typically "be_WIDGET_ZONE"</param>
        public static void PreloadWidgetsAsync(string zoneName)
        {
            //8/16/11 RonC Method Added

            //Need to access the Cache to force it to be constructed
            //while we still have HttpContext.
            CacheProvider cache = Blog.CurrentInstance.Cache;

            // Need blogSettings to pass to Ping since the current blog instance won't
            // be detectable once in a BG thread.
            Guid blogId = Blog.CurrentInstance.Id;

            ThreadPool.QueueUserWorkItem(delegate {
                // because HttpContext is not available within this BG thread
                // needed to determine the current blog instance,
                // set override value here.
                Blog.InstanceIdOverride = blogId;

                XmlDocument doc;

                // check the cache for the document. if not loaded yet, load it & put in cache
                if (Blog.CurrentInstance.Cache[zoneName] == null)
                {
                    doc = RetrieveXml(zoneName);
                    if (doc != null)
                    {
                        Blog.CurrentInstance.Cache[zoneName] = doc;
                    }
                }
                else
                {
                    doc = (XmlDocument)Blog.CurrentInstance.Cache[zoneName];
                }

                var zone = doc.SelectNodes("//widget");
                if (zone == null)
                {
                    return;
                }

                System.Web.UI.Page page = new System.Web.UI.Page();

                foreach (XmlNode widget in zone)
                {
                    var fileName = string.Format("{0}Custom/Widgets/{1}/widget.ascx", Utils.ApplicationRelativeWebRoot, widget.InnerText);
                    try {
                        bool isAdminWidget = (fileName.ToLower().IndexOf("/administration/widget.ascx") >= 0);
                        if (!isAdminWidget || (isAdminWidget && Security.IsAuthenticated))
                        {
                            //Loading the widget control now, will cause it to be in
                            //memory when a real page request comes in later because
                            //the .Net framework will cached the control.
                            page.LoadControl(fileName);
                        }
                    } catch {
                        //mask the exceptions since we are just preloading controls
                        //Later when the control is loaded for a real page request
                        //The system will show an appropriate error.
                    }
                }
            });  //end delegate
        }        //PreloadWidgets
Exemple #48
0
 public static void Include(System.Web.UI.Page page, string controlfile)
 {
     page.LoadControl(controlfile).RenderControl(new HtmlTextWriter(WebContext.Current.Response.Output));
 }