public override void RenderWebPart(HtmlTextWriter writer, WebPart webPart) { if (webPart == null) { throw new ArgumentNullException("webPart"); } base.Zone.PartChromeStyle.AddAttributesToRender(writer, base.Zone); writer.AddAttribute(HtmlTextWriterAttribute.Class, "divzone_part_chrome"); writer.RenderBeginTag(HtmlTextWriterTag.Div); if (base.WebPartManager.DisplayMode == WebPartManager.EditDisplayMode || webPart.ChromeType != PartChromeType.None || !webPart.Hidden) { this.RenderTitleBar(writer, webPart); } base.Zone.PartStyle.AddAttributesToRender(writer, base.Zone); if (webPart.Hidden && !base.WebPartManager.DisplayMode.ShowHiddenWebParts) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "divzone_part_hidden"); } else { writer.AddAttribute(HtmlTextWriterAttribute.Class, "divzone_part"); } writer.RenderBeginTag(HtmlTextWriterTag.Div); this.RenderPartContents(writer, webPart); writer.RenderEndTag(); writer.RenderEndTag(); }
private static void UpdateWebPartDataProperties(WebPartEntity webPart, WebPart webPartData, Dictionary <string, string> globalProperties) { List <Property> tempList = new List <Property>(); if (webPartData.Properties != null) { tempList.AddRange(webPartData.Properties); } foreach (var token in globalProperties) { // Add property to web part if (!webPart.Properties.ContainsKey(token.Key)) { webPart.Properties.Add(token.Key, token.Value); } // Add parameter to model tempList.Add(new Property() { Functions = "", Name = token.Key, Type = PropertyType.@string }); } webPartData.Properties = tempList.ToArray(); }
protected override void RenderContents(HtmlTextWriter writer) { WebPart webpart = WebPartToEdit; Debug.WriteLine(webpart.GetType()); Assembly current = Assembly.GetAssembly(webpart.GetType()); Debug.WriteLine(current); Assembly framework = Assembly.GetExecutingAssembly(); Debug.WriteLine(framework); writer.WriteLine("<br><center><font color='blue'>"); writer.WriteLine(current.GetName().Name.Replace(".", "<br>")); writer.WriteLine("</font><br><br>"); writer.WriteLine("Version " + current.GetName().Version); writer.WriteLine("<br>"); writer.WriteLine("*Framework " + framework.GetName().Version); writer.WriteLine("<br>"); writer.WriteLine("Copyright (c) 2008<br>"); writer.AddAttribute(HtmlTextWriterAttribute.Href, "http://www.spsprofessional.com"); writer.AddAttribute(HtmlTextWriterAttribute.Target, "_blank"); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write("<br><b>SPSProfessional<br>Professional SharePoint Components</b>"); writer.RenderEndTag(); writer.Write("<br><br>"); }
protected virtual void RenderVerbs(HtmlTextWriter writer, WebPart webPart) { if (webPart.AllowEdit) { VerbLink editLink = new VerbLink(base.Zone, "edit:" + webPart.ID); editLink.Text = "edit"; writer.Write(" "); this.RenderVerbControl(writer, editLink); } if (webPart.AllowEdit && webPart.AllowClose) { VerbLink deleteLink = new VerbLink(base.Zone, "delete:" + webPart.ID); deleteLink.Text = "delete"; writer.Write(" "); this.RenderVerbControl(writer, deleteLink); } if (webPart.ExportMode != WebPartExportMode.None) { HyperLink exportLink = new HyperLink(); exportLink.Text = "export"; exportLink.NavigateUrl = base.WebPartManager.ResolveUrl("~/download/Export.aspx" + HttpContext.Current.Request.Url.Query + "&p=" + webPart.ID); writer.Write(" "); this.RenderVerbControl(writer, exportLink); } if (webPart.AllowEdit && webPart.ExportMode != WebPartExportMode.None) { VerbLink importLink = new VerbLink(base.Zone, "import:" + webPart.ID); importLink.Text = "import"; writer.Write(" "); this.RenderVerbControl(writer, importLink); } }
public static bool IsWebPartOnPage(ClientContext ctx, string relativePageUrl, string title) { var webPartPage = ctx.Web.GetFileByServerRelativeUrl(relativePageUrl); ctx.Load(webPartPage); ctx.ExecuteQuery(); if (webPartPage == null) { return(false); } LimitedWebPartManager limitedWebPartManager = webPartPage.GetLimitedWebPartManager(PersonalizationScope.Shared); ctx.Load(limitedWebPartManager.WebParts, wps => wps.Include(wp => wp.WebPart.Title)); ctx.ExecuteQueryRetry(); if (limitedWebPartManager.WebParts.Count >= 0) { for (int i = 0; i < limitedWebPartManager.WebParts.Count; i++) { WebPart oWebPart = limitedWebPartManager.WebParts[i].WebPart; if (oWebPart.Title.Equals(title, StringComparison.InvariantCultureIgnoreCase)) { return(true); } } } return(false); }
public override void RenderWebPart(HtmlTextWriter writer, WebPart webPart) { if (webPart == null) { throw new ArgumentNullException("webPart"); } base.Zone.PartChromeStyle.AddAttributesToRender(writer, base.Zone); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); if (webPart.Hidden && !base.WebPartManager.DisplayMode.ShowHiddenWebParts) { writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none"); } writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.RenderBeginTag(HtmlTextWriterTag.Td); if (base.WebPartManager.DisplayMode == WebPartManager.EditDisplayMode || webPart.ChromeType != PartChromeType.None) { this.RenderTitleBar(writer, webPart); } writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderBeginTag(HtmlTextWriterTag.Tr); base.Zone.PartStyle.AddAttributesToRender(writer, base.Zone); writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, base.Zone.PartChromePadding.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Td); this.RenderPartContents(writer, webPart); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); }
/// <summary> /// List the web parts on a page /// </summary> /// <param name="properties">Information about the site that this method operates on</param> public void GetWebParts(string folder) { UsingContext(ctx => { Site site = ctx.Site; Web web = site.RootWeb; Microsoft.SharePoint.Client.Folder pagesLib = web.GetFolderByServerRelativeUrl(folder); ctx.Load(pagesLib.Files); ctx.ExecuteQuery(); Microsoft.SharePoint.Client.File ofile = pagesLib.Files[0]; ctx.Load(ofile); ctx.ExecuteQuery(); LimitedWebPartManager limitedWebPartManager = ofile.GetLimitedWebPartManager(PersonalizationScope.Shared); ctx.Load(limitedWebPartManager.WebParts, wps => wps.Include(wp => wp.WebPart.Title, wp => wp.Id)); ctx.ExecuteQuery(); if (limitedWebPartManager.WebParts.Count >= 0) { for (int i = 0; i < limitedWebPartManager.WebParts.Count; i++) { WebPart oWebPart = limitedWebPartManager.WebParts[i].WebPart; Console.WriteLine(oWebPart.Title); Console.WriteLine(limitedWebPartManager.WebParts[i].Id); } } }); }
public static void DeleteWebPart(ClientContext clientContext, string serverRelativeFormUrl, string WebPartTitle) { File oFile = clientContext.Web.GetFileByServerRelativeUrl(serverRelativeFormUrl); LimitedWebPartManager limitedWebPartManager = oFile.GetLimitedWebPartManager(PersonalizationScope.Shared); try { clientContext.Load(limitedWebPartManager.WebParts); clientContext.ExecuteQuery(); foreach (var webPart in limitedWebPartManager.WebParts) { clientContext.Load(webPart.WebPart); } clientContext.ExecuteQuery(); foreach (var WebPart in limitedWebPartManager.WebParts) { clientContext.Load(WebPart, w => w.WebPart.Title); clientContext.ExecuteQuery(); if (WebPart.WebPart.Title == WebPartTitle) { WebPart.DeleteWebPart(); clientContext.ExecuteQuery(); } } } catch (Exception ex) { System.Console.WriteLine("error while deleting the web part {0} from the form {1}", WebPartTitle, serverRelativeFormUrl); System.Console.WriteLine(ex.Message); } }
protected virtual void RenderVerbTag(HtmlTextWriter writer, WebPart webPart, WebPartVerb verb1, string linkClass) { var onclickscript = Zone.Page.ClientScript.GetPostBackEventReference(Zone, string.Format("{0}:{1}", GetVerbId(verb1), webPart.ID)); //var onclickscript = String.Format("__doPostBack('{0}','{2}:{1}');", Zone.UniqueID.Replace("_", "$"), webPart.ID, GetVerbId(verb1)); writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:;"); writer.AddAttribute(HtmlTextWriterAttribute.Class, linkClass); writer.AddAttribute(HtmlTextWriterAttribute.Title, GetLocalizedVerbText(verb1.Text)); writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onclickscript); writer.RenderBeginTag(HtmlTextWriterTag.A); if (String.IsNullOrEmpty(verb1.ImageUrl)) { //writer.AddAttribute(HtmlTextWriterAttribute.Class, "sn-hide"); //writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(verb1.Text); //writer.RenderEndTag(); } else { writer.AddAttribute(HtmlTextWriterAttribute.Src, verb1.ImageUrl); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); } writer.RenderEndTag(); }
protected override void ProcessWebpartProperties(WebPart webpartInstance, WebPartDefinition webpartModel) { base.ProcessWebpartProperties(webpartInstance, webpartModel); var typedWebpart = webpartInstance.WithAssertAndCast <ResultScriptWebPart>("webpartInstance", value => value.RequireNotNull()); var definition = webpartModel.WithAssertAndCast <ResultScriptWebPartDefinition>("webpartModel", value => value.RequireNotNull()); if (!string.IsNullOrEmpty(definition.DataProviderJSON)) { typedWebpart.DataProviderJSON = definition.DataProviderJSON; } if (!string.IsNullOrEmpty(definition.EmptyMessage)) { typedWebpart.EmptyMessage = definition.EmptyMessage; } if (definition.ResultsPerPage.HasValue) { typedWebpart.ResultsPerPage = definition.ResultsPerPage.Value; } if (definition.ShowResultCount.HasValue) { typedWebpart.ShowResultCount = definition.ShowResultCount.Value; } }
protected void UpdateProperties(WebPart webpart) { foreach (var item in Properties) { this.SetProperty(webpart, item.Name, item.Value); } }
public static bool IsWebPartGridListView(WebPart wp) { if (wp == null) { return(false); } var asm = Assembly.Load(Resources.WebPartsAssembly); if (asm == null) { throw new DllNotFoundException(Resources.WebPartsAssembly + ", not found"); } var types = asm.GetTypes(); var gridListViewType = types.FirstOrDefault(t => t.Name == Resources.WebPartsGridListView); if (gridListViewType == null) { throw new EntryPointNotFoundException(Resources.WebPartsAssembly + ", does not contain a definition for: " + Resources.WebPartsGridListView); } var wpType = wp.GetType(); return(gridListViewType.Equals(wpType)); }
public override WebPart GetWebPart(WebPartDescription description) { if (_UserControlMappings.ContainsKey(description.ID)) { string path = _UserControlMappings[description.ID]; Control part = null; try { part = this.Page.LoadControl(path); } catch { } if (part != null) { part.ID = description.ID; GenericWebPart webPart = this.WebPartManager.CreateWebPart(part); webPart.Title = description.Title; webPart.Description = description.Description; return(webPart); } } else if (_ServerControlMappings.ContainsKey(description.ID)) { WebPart webPart = Activator.CreateInstance(_ServerControlMappings[description.ID]) as WebPart; return(webPart); } return(null); }
public override void ApplyWebPartPersonalization(WebPart webPart) { if (this.States.ContainsKey(webPart.ID)) { this.ApplyPersonalization(webPart, this.States[webPart.ID]); } }
/// <summary> /// Deletes a web part from a page /// </summary> /// <param name="web">Site to be processed - can be root web or sub site</param> /// <param name="serverRelativePageUrl">Server relative URL of the page to remove</param> /// <param name="title">Title of the web part that needs to be deleted</param> public static void DeleteWebPart(this Web web, string serverRelativePageUrl, string title) { var webPartPage = web.GetFileByServerRelativeUrl(serverRelativePageUrl); if (webPartPage == null) { return; } web.Context.Load(webPartPage); web.Context.ExecuteQuery(); LimitedWebPartManager limitedWebPartManager = webPartPage.GetLimitedWebPartManager(PersonalizationScope.Shared); web.Context.Load(limitedWebPartManager.WebParts, wps => wps.Include(wp => wp.WebPart.Title)); web.Context.ExecuteQuery(); if (limitedWebPartManager.WebParts.Count >= 0) { for (int i = 0; i < limitedWebPartManager.WebParts.Count; i++) { WebPart oWebPart = limitedWebPartManager.WebParts[i].WebPart; if (oWebPart.Title.Equals(title, StringComparison.InvariantCultureIgnoreCase)) { limitedWebPartManager.WebParts[i].DeleteWebPart(); web.Context.ExecuteQuery(); break; } } } }
private void AddModulePart() { String moduleIDString = Request.Params.Get("addmpart"); Module module = new Module(int.Parse(moduleIDString)); //TODO: we could support filtering by module.ViewRoles if (module.AvailableForMyPage) { SiteModuleControl siteModule = Page.LoadControl("~/" + module.ControlSource) as SiteModuleControl; if (siteModule != null) { siteModule.SiteId = siteSettings.SiteId; siteModule.ID = "module" + module.ModuleId.ToString(); siteModule.ModuleConfiguration = module; siteModule.RenderInWebPartMode = true; WebPart webPart = WebPartManager1.CreateWebPart(siteModule); siteModule.ModuleId = module.ModuleId; Module.UpdateCountOfUseOnMyPage(module.ModuleId, 1); CWebPartManager CManager = (CWebPartManager)this.WebPartManager1; CManager.AddWebPart(webPart, this.CenterWebPartZone, 0); CManager.SetDirty(); } } }
protected override void RenderBody(HtmlTextWriter writer) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "tabzone_tabcontainer"); writer.RenderBeginTag(HtmlTextWriterTag.Div); foreach (TableRow row in base.Table.Rows) { foreach (TableCell cell in row.Cells) { WebPart webPart = null; string containerID = this.CreateContainerID(cell.ID); if (base.ContainersParts.ContainsKey(containerID)) { webPart = base.WebParts[base.ContainersParts[containerID]]; } if (null != webPart) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "tabzone_tabhead"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Href, "#"); writer.AddAttribute("onclick", "javascript:Toggle('" + containerID + "')"); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write(webPart.Title); writer.RenderEndTag(); writer.RenderEndTag(); } } } writer.RenderEndTag(); base.RenderBody(writer); }
protected virtual void Add(string firstPart, string firstRow, string firstCell, string firstContainer, string secondPart, string secondRow, string secondCell, string secondContainer) { if (!string.IsNullOrEmpty(secondRow) && string.IsNullOrEmpty(secondCell)) { secondContainer = this.CreateContainer(secondPart, secondRow, secondCell, secondContainer); } WebPart webPart = base.WebPartManager.WebParts[firstPart]; WebPart oldPart = base.WebParts[secondPart]; if (null != oldPart) { if (!(oldPart is ISymbolWebPart)) { throw new InvalidOperationException(string.Format("Unwanted deletion of {0}", oldPart.Title)); } base.WebPartManager.DeleteWebPart(oldPart); } WebPart newPart = null; if (webPart is ISymbolWebPart) { newPart = ((ISymbolWebPart)webPart).Instantiate(this, base.WebParts.Count); } else { newPart = base.WebPartManager.AddWebPart(webPart, this, base.WebParts.Count); } if (null == newPart) { throw new InvalidOperationException("Failed to lwas.add"); } this._containersParts[secondContainer] = newPart.ID; }
private static void UpdateWebPartDataProperties(WebPartEntity webPart, WebPart webPartData, Dictionary <string, string> globalProperties) { List <Property> tempList = new List <Property>(); if (webPartData.Properties != null) { tempList.AddRange(webPartData.Properties); } foreach (var token in globalProperties) { // Add property to web part if (!webPart.Properties.ContainsKey(token.Key)) { webPart.Properties.Add(token.Key, token.Value); } // Only add the global property once as the webPartData.Properties collection is reused across web parts and pages var propAlreadyAdded = tempList.Where(p => p.Name.Equals(token.Key, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); if (propAlreadyAdded == null) { // Add parameter to model tempList.Add(new Property() { Functions = "", Name = token.Key, Type = PropertyType.@string }); } } webPartData.Properties = tempList.ToArray(); }
protected override void RenderContents(HtmlTextWriter writer) { WebPart webpart = WebPartToEdit; Debug.WriteLine(webpart.GetType()); Assembly current = Assembly.GetAssembly(webpart.GetType()); Debug.WriteLine(current); Assembly framework = Assembly.GetExecutingAssembly(); FileVersionInfo frameworkFileViersion = FileVersionInfo.GetVersionInfo(framework.Location); FileVersionInfo currentFileViersion = FileVersionInfo.GetVersionInfo(current.Location); Debug.WriteLine(framework); Debug.WriteLine(SPSTools.GetWssVersion()); writer.WriteLine("<br><center><font color='blue'>"); writer.WriteLine(current.GetName().Name.Replace(".", "<br>")); writer.WriteLine("</font><br><br>"); writer.WriteLine("Version DLL " + current.GetName().Version); writer.WriteLine("<br/>"); writer.WriteLine("Version Rev " + currentFileViersion.FileVersion); writer.WriteLine("<br/>"); writer.WriteLine("Framework Base " + framework.GetName().Version); writer.WriteLine("<br/>"); writer.WriteLine("Framework Version " + frameworkFileViersion.FileVersion); writer.WriteLine("<br/>"); writer.WriteLine("Wss Version " + SPSTools.GetWssVersion()); writer.WriteLine("<br/><br/>"); writer.WriteLine("Copyright (c) 2008/2009<br>"); writer.AddAttribute(HtmlTextWriterAttribute.Href, "http://www.spsprofessional.com"); writer.AddAttribute(HtmlTextWriterAttribute.Target, "_blank"); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write("<br><b>SPSProfessional<br>Professional SharePoint Components</b>"); writer.RenderEndTag(); writer.Write("<br><br>"); }
private void AddWebPart() { String webPartIDString = Request.Params.Get("addpart"); if (webPartIDString.Length == 36) { Guid webPartID = new Guid(webPartIDString); WebPartContent webPartContent = new WebPartContent(webPartID); if ((webPartContent.WebPartId != Guid.Empty) && (webPartContent.AvailableForMyPage)) { if (HttpContext.Current != null) { String path = HttpContext.Current.Server.MapPath("~/bin") + Path.DirectorySeparatorChar + webPartContent.AssemblyName + ".dll"; Assembly assembly = Assembly.LoadFrom(path); Type type = assembly.GetType(webPartContent.ClassName, true, true); WebPart webPart = Activator.CreateInstance(type) as WebPart; if (webPart != null) { WebPartContent.UpdateCountOfUseOnMyPage(webPartContent.WebPartId, 1); webPart.ID = Guid.NewGuid().ToString(); CWebPartManager CManager = (CWebPartManager)this.WebPartManager1; CManager.AddWebPart(webPart, this.CenterWebPartZone, 0); CManager.SetDirty(); } } } } }
private void AddPortletSkinCss(HtmlTextWriter writer, WebPart webPart, String chromeType) { var portletSkinName = "sn-portlet sn-{1} {0} sn-chrome-{2} ui-widget"; var portletBase = webPart as PortletBase; if (portletBase != null) { var skinPrefix = String.Empty; var portletTypeName = String.Empty; skinPrefix = portletBase.SkinPreFix; portletTypeName = portletBase.GetType().Name; if (String.IsNullOrEmpty(skinPrefix)) { portletSkinName = "sn-portlet sn-{0} sn-chrome-{1} ui-widget"; portletSkinName = String.Format(portletSkinName, portletTypeName.ToLower(), chromeType); } else { portletSkinName = String.Format(portletSkinName, skinPrefix, portletTypeName.ToLower(), chromeType); } } writer.AddAttribute(HtmlTextWriterAttribute.Class, portletSkinName); }
protected void LoadWebPart() { String partIDString = String.Empty; if (Settings.Contains("WebPartModuleWebPartSetting")) { partIDString = Settings["WebPartModuleWebPartSetting"].ToString(); } if (partIDString.Length == 36) { Guid webPartID = new Guid(partIDString); WebPartContent webPartContent = new WebPartContent(webPartID); if (webPartContent.WebPartId != Guid.Empty) { String path = HttpContext.Current.Server.MapPath("~/bin") + Path.DirectorySeparatorChar + webPartContent.AssemblyName + ".dll"; Assembly assembly = Assembly.LoadFrom(path); Type type = assembly.GetType(webPartContent.ClassName, true, true); WebPart webPart = Activator.CreateInstance(type) as WebPart; if (webPart != null) { this.Title = webPart.Title; this.Description = webPart.Description; this.ModuleConfiguration.ModuleTitle = webPart.Title; this.pnlPlaceHolder.Controls.Add(webPart); } } } }
public override WebPart CreateWebPart(SPWeb web, Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager webPartManager) { SPQuery qry = new SPQuery(); qry.Query = String.Format(CultureInfo.CurrentCulture, "<Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='File'>{0}</Value></Eq></Where>", this.WebpartName); SPList webPartGallery = null; if (web.ParentWeb == null) { webPartGallery = web.GetCatalog( SPListTemplateType.WebPartCatalog); } else { webPartGallery = web.Site.RootWeb.GetCatalog( SPListTemplateType.WebPartCatalog); } SPListItemCollection webParts = webPartGallery.GetItems(qry); XmlReader xmlReader = new XmlTextReader(webParts[0].File.OpenBinaryStream()); string errorMsg; WebPart webPart = webPartManager.ImportWebPart(xmlReader, out errorMsg); //webPart.Hidden = isHidden; base.UpdateProperties(webPart); return(webPart); }
protected virtual void RenderTitleBar(HtmlTextWriter writer, WebPart webPart) { writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); base.Zone.PartTitleStyle.AddAttributesToRender(writer, base.Zone); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Title, webPart.Description, true); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.WriteEncodedText(webPart.Title); writer.RenderEndTag(); writer.RenderEndTag(); base.Zone.PartTitleStyle.AddAttributesToRender(writer, base.Zone); writer.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, TextAlign.Right.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Td); if (base.WebPartManager.DisplayMode == WebPartManager.EditDisplayMode) { this.RenderVerbs(writer, webPart); } writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); }
/// <summary> /// Check all webpart in the specified webpartpage /// </summary> /// <param name="CurrentFile"></param> protected void CrawlWebPartPage(SPFile CurrentFile) { using (SPWeb web = CurrentFile.ParentFolder.ParentWeb) { SPWebPartCollection parts = web.GetWebPartCollection(CurrentFile.Url, Storage.Shared); if (parts != null) { //OnTrace("Start search " + CurrentFile.Url.ToString() + " webpart's page...", ""); for (int i = 0; i < parts.Count; i++) { using (WebPart wptWebPart = parts[i]) { if (WebPartInWebPartList(wptWebPart)) { string[] webPartNames = wptWebPart.ToString().Split('.'); string WebPartSmallName = webPartNames[webPartNames.Length - 1].ToString(); OnTrace("Start search webpart " + WebPartSmallName, ""); try { PropertyInfo[] pinProperties = wptWebPart.GetType().GetProperties( BindingFlags.Public | BindingFlags.Instance); try { foreach (PropertyInfo p in pinProperties) { if (FindReplaceWebPartProperty(wptWebPart, p)) { parts.SaveChanges(wptWebPart.StorageKey); } } } catch (Exception ex) { string sre = ex.Message; } } catch (Exception ex) { string s = ex.Message; } OnTrace("Finish search webpart " + WebPartSmallName, ""); } GC.Collect(); GC.WaitForPendingFinalizers(); } } } GC.Collect(); GC.WaitForPendingFinalizers(); } //OnTrace("Finish search " + CurrentFile.Url.ToString() + " webpart's page...", ""); }
protected override void CreateChildControls() { this.WebPart = (SliderWebPart)this.WebPartToEdit; this.Title = WebPart.LoadResource("Slider_Source_List"); Panel pnlToolPart = new Panel(); pnlToolPart.CssClass = "UserSectionHead"; // List label Panel pnlListField = new Panel(); pnlListField.CssClass = "UserSectionHead"; this.lblList.ID = "lblList"; this.lblList.AssociatedControlID = "txtEntityPath"; this.lblList.Text = " "; // WebPart.LoadResource("Slider_Source_List"); pnlListField.Controls.Add(this.lblList); pnlToolPart.Controls.Add(pnlListField); // List icon and list name panel Panel pnlList = new Panel(); pnlList.Style.Add("padding", "2px 5px"); pnlList.Style.Add("width", "145px"); pnlList.Style.Add("float", "left"); pnlList.Style.Add("overflow", "hidden"); pnlList.Style.Add("margin", "0 5px 5px 0"); pnlList.Style.Add("border", "#ccc 1px solid"); // List icon this.imgListIcon.Style.Add("float", "left"); this.imgListIcon.Style.Add("margin", "0 5px 0 0"); pnlList.Controls.Add(this.imgListIcon); // Entity name textbox this.lblListTitle.ID = "txtEntityPath"; this.lblListTitle.CssClass = "UserInput"; this.lblListTitle.Style.Add("margin", "4px 0 0 0"); pnlList.Controls.Add(this.lblListTitle); pnlToolPart.Controls.Add(pnlList); // Entity ID hidden field pnlToolPart.Controls.Add(this.hdnListIdentifier); // Browse button Button btnBrowse = new Button(); btnBrowse.CssClass = "UserButton"; btnBrowse.Style.Add("float", "left"); btnBrowse.OnClientClick = String.Format("LaunchPickerTreeDialog('CbqPickerSelectListTitle','CbqPickerSelectListText','{0}','', '{1}', null,'','','/_layouts/images/smt_icon.gif','', callback, ''); return false;", "listsOnly", SPContext.Current.Web.Url); btnBrowse.Text = "..."; pnlToolPart.Controls.Add(btnBrowse); this.Controls.Add(pnlToolPart); base.CreateChildControls(); }
private static void ConnectWebParts(SPLimitedWebPartManager _pageMgr, WebPart _prvdr, WebPart _cnsmr, string _providerConnectionPoints, string _consumerConnectionPoints) { _pageMgr.SPConnectWebParts( _prvdr, _pageMgr.GetProviderConnectionPoints(_prvdr)[_providerConnectionPoints], _cnsmr, _pageMgr.GetConsumerConnectionPoints(_cnsmr)[_consumerConnectionPoints]); }
public override void PartCommunicationConnect(string interfaceName, WebPart connectedPart, string connectedInterfaceName, ConnectionRunAt runAt) { if (interfaceName == "MyPlannerCellConsumerInterface_WPQ_") { webpartConnected = true; _cellConnectedCount++; } }
public WebPartConnectionsEventArgs (WebPart providerPart, ProviderConnectionPoint providerPoint, WebPart consumerPart, ConsumerConnectionPoint consumerPoint, WebPartConnection connection) { this.providerPart = providerPart; this.providerPoint = providerPoint; this.consumerPart = consumerPart; this.consumerPoint = consumerPoint; this.connection = connection; }
private void WebPartManager_WebPartDeleting(object sender, WebPartCancelEventArgs e) { WebPart part = e.WebPart; if (part != null && !(part is ISymbolWebPart) && part.Zone == this) { base.WebPartManager.AddWebPart(this.CreateEmptyWebPart(), part.Zone, part.ZoneIndex); } }
public void SetIsStatic(WebPart webPart, bool isStatic) { }
public void CallOnClosing(WebPart webPart) { }
public void SetIsStandalone(WebPart webPart, bool isStandalone) { }
public virtual bool IsDefaultWebPart(WebPart webPart) { XElement xmlDefWebPart = XElement.Parse(this.WebPartDefaultSchema); XElement xmlWebPart = XElement.Parse(webPart.Contents); PrepareToCompare(xmlDefWebPart); PrepareToCompare(xmlWebPart); bool result = XElement.DeepEquals(xmlDefWebPart, xmlWebPart); return result; }
// Constructors public WebPartEventArgs(WebPart webPart) { }
// Constructors public WebPartCancelEventArgs(WebPart webPart) { }
public void RemoveWebPart(WebPart webPart) { }
public void SetConnectErrorMessage(WebPart webPart, string connectErrorMessage) { }
public string GetZoneID(WebPart webPart) { }
// Methods public void AddWebPart(WebPart webPart) { }
public void CallOnEditModeChanged(WebPart webPart) { }
// Constructors public WebPartMovingEventArgs(WebPart webPart, WebPartZoneBase zone, int zoneIndex) { }
// Constructors public UnauthorizedWebPart(WebPart webPart) { }
public WebPartEventArgs (WebPart part) { this.part = part; }
public void SetHasSharedData(WebPart webPart, bool hasSharedData) { }
public WebPartConnectionsEventArgs(WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint, WebPartConnection connection) { }
public WebPartConnectionsEventArgs (WebPart providerPart, ProviderConnectionPoint providerPoint, WebPart consumerPart, ConsumerConnectionPoint consumerPoint) : this (providerPart, providerPoint, consumerPart, consumerPoint, null) {}
protected string GetWebPartPropertyValue(WebPart wp, string propertyName) { var prop = wp.Properties.FirstOrDefault(x => x.Name.Equals(propertyName, StringComparison.InvariantCultureIgnoreCase)); return prop == null ? null : prop.Value; }
public void SetIsClosed(WebPart webPart, bool isClosed) { }
public static IWebPartSchemaComparer CreateTypedComparer(WebPart webpart) { IWebPartSchemaComparer result = null; if (WebPartsModelProvider.IsV3FormatXml(webpart.Contents)) { if (-1 != webpart.Contents.IndexOf(@"<type name=""Microsoft.SharePoint.WebPartPages.XsltListViewWebPart", StringComparison.OrdinalIgnoreCase)) { result = new XsltListViewWebPartComparer(); } } else { if (-1 != webpart.Contents.IndexOf("<TypeName>Microsoft.SharePoint.WebPartPages.ListFormWebPart</TypeName>", StringComparison.OrdinalIgnoreCase)) { result = new ListFormWebPartComparer(); } } return result; }
public void SetIsShared(WebPart webPart, bool isShared) { }
public void SetHasUserData(WebPart webPart, bool hasUserData) { }
public abstract virtual void ExtractWebPartPersonalization(WebPart webPart) {}
public abstract virtual void SetWebPartDirty(WebPart webPart) {}
public void SetZoneIndex(WebPart webPart, int zoneIndex) { }
public WebPartDescription(WebPart part) { }
public void CallOnConnectModeChanged(WebPart webPart) { }
public void SetZoneID(WebPart webPart, string zoneID) { }
public void CallOnDeleting(WebPart webPart) { }