/// <summary> /// Load the user control required /// </summary> protected override void CreateChildControls() { base.CreateChildControls(); if (SPContext.Current.IsDesignTime) { Controls.Clear(); Controls.Add(new Literal { Text = string.Format("Container WebPart {0}", string.IsNullOrEmpty(UserControlPath) ? "(No User Control Specified)" : UserControlPath) }); } else { if (WebPartManager.DisplayMode == WebPartManager.BrowseDisplayMode) { if (!MustRenderFolderCreator()) { if (string.IsNullOrEmpty(UserControlPath)) { Controls.Clear(); Controls.Add(new Literal { Text = "(No User Control Specified)" }); } else { try { userControl = Page.LoadControl(UserControlPath); Controls.Add(userControl); } catch (Exception ex) { Controls.Clear(); Controls.Add(new Literal { Text = string.Format("Container WebPart ({0})", ex.Message) }); } } } else { renderFolderCreator = true; createdModifiedInfo = new CreatedModifiedInfo(); Controls.Add(createdModifiedInfo); } } else { Controls.Clear(); Controls.Add(new Literal { Text = string.Format("Container WebPart {0}", string.IsNullOrEmpty(UserControlPath) ? "(No User Control Specified)" : UserControlPath) }); } } }
/// <summary> /// Load the user control required /// </summary> protected override void CreateChildControls() { base.CreateChildControls(); if (SPContext.Current.IsDesignTime) { Controls.Clear(); Controls.Add(new Literal { Text = string.Format("Container WebPart {0}", string.IsNullOrEmpty(UserControlPath) ? "(No User Control Specified)" : UserControlPath) }); } else { if (WebPartManager != null && WebPartManager.DisplayMode == WebPartManager.BrowseDisplayMode) { if (!MustRenderFolderCreator()) { if (string.IsNullOrEmpty(UserControlPath)) { Controls.Clear(); Controls.Add(new Literal { Text = "(No User Control Specified)" }); } else { try { var path = UserControlPath.Replace("$Site", SPContext.Current.Web.ServerRelativeUrl).Replace("//", "/"); userControl = Page.LoadControl(path); Controls.Add(userControl); } catch (Exception ex) { Controls.Clear(); var trace = new StackTrace(ex, true); var message = trace.ToString().Replace("\n\n", "<br/>"); Controls.Add(new Literal { Text = string.Format("Container WebPart: {0}<br/>{1}", ex.Message, message) }); } } } else { renderFolderCreator = true; createdModifiedInfo = new CreatedModifiedInfo(); Controls.Add(createdModifiedInfo); } } else { Controls.Clear(); Controls.Add(new Literal { Text = string.Format("Container WebPart {0}", string.IsNullOrEmpty(UserControlPath) ? "(No User Control Specified)" : UserControlPath) }); } } }
/// <summary> /// Load the user control required /// </summary> protected override void CreateChildControls() { base.CreateChildControls(); if (SPContext.Current.IsDesignTime) { Controls.Clear(); Controls.Add(new Literal { Text = string.Format(CultureInfo.InvariantCulture, "Container WebPart {0}", string.IsNullOrEmpty(this.UserControlPath) ? "(No User Control Specified)" : this.UserControlPath) }); } else { if (WebPartManager.DisplayMode == WebPartManager.BrowseDisplayMode) { if (!this.MustRenderFolderCreator()) { if (string.IsNullOrEmpty(this.UserControlPath)) { Controls.Clear(); Controls.Add(new Literal { Text = "(No User Control Specified)" }); } else { try { this.userControl = Page.LoadControl(this.UserControlPath); Controls.Add(this.userControl); } catch (Exception ex) { Controls.Clear(); Controls.Add(new Literal { Text = string.Format(CultureInfo.InvariantCulture, "Container WebPart ({0})", ex.Message) }); throw; } } } else { this.renderFolderCreator = true; this.createdModifiedInfo = new CreatedModifiedInfo(); Controls.Add(this.createdModifiedInfo); } } else { Controls.Clear(); Controls.Add(new Literal { Text = string.Format(CultureInfo.InvariantCulture, "Container WebPart {0}", string.IsNullOrEmpty(UserControlPath) ? "(No User Control Specified)" : this.UserControlPath) }); if (this.UserControlPath.Contains("HeaderUC.ascx")) { try { this.userControl = Page.LoadControl("UserControls/InitUC.ascx"); Controls.Add(this.userControl); } catch (Exception ex) { Controls.Clear(); Controls.Add(new Literal { Text = string.Format(CultureInfo.InvariantCulture, "Container WebPart ({0})", ex.Message) }); throw; } } } } }
/// <summary> /// Load the user control required /// </summary> protected override void CreateChildControls() { base.CreateChildControls(); if (SPContext.Current.IsDesignTime) { Controls.Clear(); Controls.Add(new Literal { Text = string.Format("Container WebPart {0}", string.IsNullOrEmpty(UserControlPath) ? "(No User Control Specified)" : UserControlPath) }); } else { if (WebPartManager.DisplayMode == WebPartManager.BrowseDisplayMode) { if (!MustRenderFolderCreator()) { if (string.IsNullOrEmpty(UserControlPath)) { Controls.Clear(); Controls.Add(new Literal { Text = "(No User Control Specified)" }); } else { try { userControl = Page.LoadControl(UserControlPath); Controls.Add(userControl); } catch (Exception ex) { Controls.Clear(); Controls.Add(new Literal { Text = string.Format("Container WebPart ({0})", ex.Message) }); } } } else { renderFolderCreator = true; createdModifiedInfo = new CreatedModifiedInfo(); Controls.Add(createdModifiedInfo); } } else { Controls.Clear(); Controls.Add(new Literal { Text = string.Format("Container WebPart {0}", string.IsNullOrEmpty(UserControlPath) ? "(No User Control Specified)" : UserControlPath) }); } } }