当前位置: 首页>>代码示例>>C#>>正文


C# Page.LoadControl方法代码示例

本文整理汇总了C#中System.Web.UI.Page.LoadControl方法的典型用法代码示例。如果您正苦于以下问题:C# Page.LoadControl方法的具体用法?C# Page.LoadControl怎么用?C# Page.LoadControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.Page的用法示例。


在下文中一共展示了Page.LoadControl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Load

        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;
        }
开发者ID:sigcms,项目名称:Seeger,代码行数:25,代码来源:WidgetControlLoader.cs

示例2: GetEditControl

        /// <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;
        }
开发者ID:dineshkummarc,项目名称:DotNetPortalSrc-102,代码行数:41,代码来源:Helper.cs

示例3: CreateSearchControl

        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;
        }
开发者ID:mehmetgoren,项目名称:AppX.Reporting,代码行数:33,代码来源:ReportParameterFilters.cs

示例4: GetActivityPrimitive

 /// <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");
     }
 }
开发者ID:0anion0,项目名称:IBN,代码行数:18,代码来源:ActivityFactory.cs

示例5: RenderTemplateHtml

        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();
        }
开发者ID:xwyangjshb,项目名称:cuyahoga,代码行数:26,代码来源:ViewUtil.cs

示例6: RenderView

        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);
        }
开发者ID:FishBasketGordo,项目名称:Creelio.Framework,代码行数:7,代码来源:ViewUtility.cs

示例7: Render

        /// <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();
        }
开发者ID:webxiaohua,项目名称:SmartNetMVC,代码行数:37,代码来源:UcExecutor.cs

示例8: LoadControl

        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;
        }
开发者ID:timbooker,项目名称:dotObjects,代码行数:25,代码来源:WebFormsRenderer.cs

示例9: GetModuleUserSettings

        /// <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;
        }
开发者ID:divyang4481,项目名称:appleseedapp,代码行数:49,代码来源:ModuleSettingsCustom.cs

示例10: ExecutePrayerTimes

        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();
            }
        }
开发者ID:yalhami,项目名称:eXpresso,代码行数:28,代码来源:PrayerTimesWebService.asmx.cs

示例11: GetHtmlEventItems

        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();
            }
        }
开发者ID:yalhami,项目名称:eXpresso,代码行数:28,代码来源:EventWebService.asmx.cs

示例12: RenderControl

        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();
        }
开发者ID:jackiechou,项目名称:thegioicuaban.com,代码行数:33,代码来源:ControlExtenders.cs

示例13: UpdateImage

        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;
		}
开发者ID:phaniarveti,项目名称:Experiments,代码行数:33,代码来源:ImageViewerUpdater.asmx.cs

示例14: RenderView

        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();
        }
开发者ID:philippkueng,项目名称:hammyoncoffeine,代码行数:35,代码来源:ViewManager.cs

示例15: RenderView

 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();
 }
开发者ID:kcly3027,项目名称:freePhoto,代码行数:10,代码来源:orders.aspx.cs


注:本文中的System.Web.UI.Page.LoadControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。