Programatically adding web parts to pages
I am using a site provisioning event receiver and am trying to add the ProjectSummaryWebPart and the GettingStartedWebPart to the page. I am using the code below but when I go browse the page it looks like this. Has anyone had any experience with programmatically
adding these web parts to a page using server side code?
ProjectSummaryWebPart pswp = new ProjectSummaryWebPart
Title = "Project Summary",
ChromeType = PartChromeType.TitleOnly
wpmgr.AddWebPart(pswp, "Header", 0);
GettingStartedWebPart gswp = new GettingStartedWebPart {
ChromeType = PartChromeType.TitleOnly,
Title = "Get Started with your project site",
wpmgr.AddWebPart(gswp, "Header", 1);
Hi,
I can reproduce this issue by adding the Project Summary Web Part into a page, when I change the PartChromeType to “BorderOnly”, the duplicated title will disappear.
Anyway, when editing the page contains the Project Summary Web Part added programmatically, the ribbon will be blocked by an undefined error in projectsummary.js.
As the limited resource we have, I would suggest you open a ticket for this case:
http://support.microsoft.com
Thanks
Patrick Liang
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Patrick Liang
TechNet Community Support
Similar Messages
-
How to add SharePoint 2013 Promoted link list view web part in page programatically with Tiles view using CSOM. I found that it can be
done by using XsltListViewWebPart class but how can I use this one by using shraepoint client api.
shivNice, can you point me to the solution please ?
I'm trying to do this but I get an error :
Web Part Error: Cannot complete this action. Please try again. Correlation ID: blablabla
StackTrace: at Microsoft.SharePoint.SPViewCollection.EnsureViewSchema(Boolean fullBlownSchema, Boolean bNeedInitallViews) at Microsoft.SharePoint.SPList.GetView(Guid viewGuid)
All help really appreciated. -
Resize Content Editor Web Part to Page Width
I have a content editor web part in page. The CEWP contains a javascript based menu and an Iframe.
The problem is that when I resize the page, the width of the CEWP does not size to the width of the browser.
How can I get the CEWP to resize to the browser?John BailoJohn, can you provide insight on the script you used for this? I'm trying to accomplish the same thing.
-
2013 Custom Web Parts in Page Layouts not showing for users
Custom Web Parts in Page Layouts not showing for users
I have created a master page in the root site collection for a subsite I am developing. I created content types and custom page layouts for the pages within the subsite.
I used the snippet tool in the design manager to create web parts and page field markup which I copied into the custom layout HTML pages in the root site collection. For instance I have an image viewer web part that I place there to serve as a section title.
The problem is that I can see all these customer layout page parts no problem but my users cannot. This leads me to believe its permissions, I am site owner of both the subsite and root site collection.
The users that cannot see the web parts are site members of the site and restricted read users on the root site collection (where the layouts are stored).
What gives I'm finding it hard to understand why a snipet generated web part wouldn't show in all pages created from that layout page.
Any help would be appreciated, Havent found anything on this issue online. weird.It is a permission issue indeed. Fix is simple, make sure you check out the page layout page, then check it back in as published version.
John Architect -
I put a Business Data List web part on a Web Part Page in SharePoint 2010. The page is being cached. I keep getting old, same, and incorrect results all the time whenever I click the Retrieve button.
How can I stop the Page from being cached? Thanks.
MayankHi,
According to your post, my understanding is that you wanted to stop the Web Part or Page from being cached.
Per my knowleadge, the default implementation of the BDC service and the related Web Parts do not provide a caching mechanism for storing the retrieved information. The entity information is retrieved from the BDC and is stored
directly into the ASP.NET cache. You can refer to:
Caching in SharePoint
I recommend to open the web.config file in SharePoint's web site and change to
<WebPartCache Storage="None" />, then restart IIS (iisreset at a command prompt will do).
More information:
SharePoint and Web Part Caching
Web Parts and Caching
Thanks,
Linda Li
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Linda Li
TechNet Community Support -
Fresh install: Discussion Board item "alert me" errors Web Parts Maintenance Page
This happens on a freshly installed Sharepoint 2013 Foundation standalone server.
I create a standard Discussion board app and add a discussion post. I enter the post, and use the "alert me" option (under the post, not in the top ribbon). I hit ok on the alert settings and get the "sorry, something went wrong"
page. Doesn't matter what user tries to use the "alert me" option, same error occurs. Doesn't matter if I create a new web application or site collection, Discussion board always does this. Just to note, even though there is an error, the alert is
still created.
An unexpected error has
occurred.
Web
Parts Maintenance Page: If you have permission, you can use this page to
temporarily close Web Parts or remove personal settings. For more information,
contact your site administrator.
Application error when access /Lists/tax discussion/Flat.aspx, Error=Value does not fall within the expected range.
at Microsoft.SharePoint.SPContentTypeId..ctor(String id)
at Microsoft.SharePoint.SPViewContext.get_FolderContentTypeId()
at Microsoft.SharePoint.WebControls.ViewSelectorMenu.AddMenuItems()
at Microsoft.SharePoint.WebControls.ToolBarMenuButton.CreateChildControls()
at Microsoft.SharePoint.WebControls.ViewSelectorMenu.CreateChildControls()
at System.Web.UI.Control.EnsureChildControls()
at Microsoft.SharePoint.WebControls.TemplateBasedControl.OnLoad(EventArgs e)
at Microsoft.SharePoint.WebControls.ToolBarMenuButton.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.AddedControl(Control control, Int32 index)
at Microsoft.SharePoint.WebPartPages.XsltListViewWebPart.CreateChildControls()
at Microsoft.SharePoint.WebPartPages.WebPartMobileAdapter.CreateChildControls()
at System.Web.UI.Control.EnsureChildControls()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
System.ArgumentException: Value does not fall within the expected range.
at Microsoft.SharePoint.SPContentTypeId..ctor(String id)
at Microsoft.SharePoint.SPViewContext.get_FolderContentTypeId()
at Microsoft.SharePoint.WebControls.ViewSelectorMenu.AddMenuItems()
at Microsoft.SharePoint.WebControls.ToolBarMenuButton.CreateChildControls()
at Microsoft.SharePoint.WebControls.ViewSelectorMenu.CreateChildControls()
at System.Web.UI.Control.EnsureChildControls()
at Microsoft.SharePoint.WebControls.TemplateBasedControl.OnLoad(EventArgs e)
at Microsoft.SharePoint.WebControls.ToolBarMenuButton.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.AddedControl(Control control, Int32 index)
at Microsoft.SharePoint.WebPartPages.XsltListViewWebPart.CreateChildControls()
at Microsoft.SharePoint.WebPartPages.WebPartMobileAdapter.CreateChildControls()
at System.Web.UI.Control.EnsureChildControls()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)This issue is known by Microsoft but there is no ETA on a fix. My case for this issue was closed a few days ago on this problem.
Trevor Seward, MCC
Follow or contact me at...
  
This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs. -
Add and edit content editor web part to pages in bulk.
Hello,
I had recently posted a question 'Build pages in
bulk' and thanks to
Alex Brassington, I was able to do just that. Now, I want to take this PS script and XML file to the next level. Currently I am using page content to add simple text to each pages in bulk. Now, I'd like to add the Content Editor webpart and also add text
in it in bulk. Is that possible? Below is the code for both the PS and the XML. The script is run as
PS c:\scripts> .\New-Page.ps1 “c:\pages.xml”
http://SharePoint.contoso.com/sites/TestSite
New-Page.ps1
[xml]$pagesXML = Get-Content $args[0]
$siteUrl = $args[1]
$web = Get-SPWeb $siteURL
$pub = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$pagesXML.Pages.Page | ForEach-Object {
$fileName = $_.FileName
$title = $_.Title
$articleType = $_.ArticleType #Choice fields just need a string value
$contact = Get-SPUser -Identity $_.Contact -web $web
$reviewDate = [DateTime]::Now.AddDays($_.ReviewDate)
$pagecontent = $_.PageContent
#Below I replace a token in the XML to get the absolute url
#else it will error with subwebs, even if using relative with or without /
$pubPageLayout = $_.PubPageLayout -replace "{siteUrl}", $siteUrl
Write-Host "Creating page $fileName"
$newPage = $pub.AddPublishingPage()
$newPage.ListItem["BaseName"] = $fileName
$newPage.ListItem["Title"] = $title
$newPage.ListItem["PublishingPageLayout"] = $pubPageLayout
$newPage.Update() #Must update here so we can access our custom columns
$newPage.ListItem["Contact"] = $contact
$newPage.ListItem["Page Content"] = $pagecontent
$newPage.Update()
$newPage.CheckIn("")
$newPage.ListItem.File.Publish("")
Write-Host "Published"
Write-Host "Completed!"
# Dispose
$web.Dispose()
$site.Dispose()
Pages.xml
<?xml version="1.0" encoding="utf-8"?>
<Pages>
<Page>
<FileName>Teampaintballcomp1</FileName>
<Title>Team paintball comp1</Title>
<PubPageLayout>http://sharepoint.contoso.com/sites/testsite/_catalogs/masterpage/CustomWikiPage.aspx</PubPageLayout>
<Contact>AD-Ent\TestAccount</Contact>
<PageContent>
This is some text.
This is another line of text.
</PageContent>
</Page>
<Page>
<FileName>Teampaintballcomp2</FileName>
<Title>Team paintball comp2</Title>
<PubPageLayout>http://sharepoint.contoso.com/sites/testsite/_catalogs/masterpage/CustomWikiPage.aspx</PubPageLayout>
<Contact>AD-Ent\TestAccount</Contact>
<PageContent>
This is some text.
This is another line of text.
</PageContent>
</Page>
<Page>
<FileName>Teampaintballcomp3</FileName>
<Title>Team paintball comp3</Title>
<PubPageLayout>http://sharepoint.contoso.com/sites/testsite/_catalogs/masterpage/CustomWikiPage.aspx</PubPageLayout>
<Contact>AD-Ent\TestAccount</Contact>
<PageContent>
This is some text.
This is another line of text.
</PageContent>
</Page>
<Page>
<FileName>Teampaintballcomp4</FileName>
<Title>Team paintball comp4</Title>
<PubPageLayout>http://sharepoint.contoso.com/sites/testsite/_catalogs/masterpage/CustomWikiPage.aspx</PubPageLayout>
<Contact>AD-Ent\TestAccount</Contact>
<PageContent>
This is some text.
This is another line of text.
</PageContent>
</Page>
</Pages>If i just fill the .txt file that is linked to the CEWP the web part div scales fine, but adding a nested div or an image and it doesn't scale down.
-
InfoPath Form Web Part breaking page left alignment
I have tried both a wiki page and a web part page and met with the same results. I am using the Oslo theme. I add two web parts (SharePoint List Filter and Listview App) and it works perfectly and the page looks normal.
When I add the InfoPath Form web part (I have tried different layouts and different zones) it causes the left alignment of the page to be way off.
See pics below.
Any suggestions?
Any help would be really appreciated!!Hi,
We have reproduced this issue. The page left alignment is broken and the page is rightward after the InfoPath Form web part is added. It happens both on the wiki page and the web part page.
Thank you for bring this issue to our attention, your time and efforts on this matter are highly appreciate. It could be a potential issue in SharePoint 2013.
In our behalf, we will put your finding to our suggestion box and report it internally. If there is any update, we will keep you informed in this thread.
Thanks.
Tracy Cai
TechNet Community Support -
Programmatically Added Web Part Issues - Powershell
Hello!
I have been doing quite a bit of research on this for the last few days but so far to no avail. What I am trying to do is use a powershell script to create a Content Editor Web Part on a basic sharepoint site created using the Team Site template.
The issue I'm running into is when I use the script I have to add a new web part to the "wpz" zone. The webpart gets created properly and exists in the webparts collection however it does not show up on the page. I can bind to the webpart through
powershell and can see that the visible property is set to true while the hidden property is false. The webpart is not closed it simply doesn't show up.
When I add the webpart to another zone it shows up properly however as soon as you edit the page the webpart disappears. However this only happens while the page is in edit mode. As soon as you save the page the programmatically added webpart immediately
shows back up in the zone it's supposed to be in.
I was wondering if anyone else had ever experienced this specific issue and if there is anything I can do to fix it.
The environment is a development box running Microsoft Server 2012 and is hosting Sharepoint 2013.
Thanks!Hello Patrick,
Thanks for your response. The script I am using is in the following code block:
$SiteUrl = "http://maddevsp01.btdev.net/my/personal/14736"
$WebUrl = "http://maddevsp01.btdev.net/my/personal/14736"
function main() {
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$OpenWeb = Get-SPWeb $WebUrl
$OpenSite = Get-SPSite $SiteUrl
$file = $OpenWeb.GetFile("$WebURL/SitePages/Home.aspx")
$WebPartManager = $file.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
Add-ContentEditorWebPart "$WebURL" "$WebURL/SitePages/Home.aspx" "wpz" 12 "Test" "Test webpart"
$OpenWeb.Dispose()
function Add-ContentEditorWebPart($SiteURL, $pageUrl, $webpartzone, $index, $title, $content)
$site = new-object Microsoft.SharePoint.SPSite($SiteURL)
$web=$site.OpenWeb()
$webpartmanager = $web.GetLimitedWebPartManager($pageUrl, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$webpart = new-object Microsoft.SharePoint.WebPartPages.ContentEditorWebPart
$webpart.ChromeType = [System.Web.UI.WebControls.WebParts.PartChromeType]::Default;
$webpart.Title = $title
$docXml = New-Object System.Xml.XmlDocument
$contentXml = $docXml.CreateElement("Content");
$contentXml.set_InnerText($content);
$docXml.AppendChild($contentXml);
$webpart.Content = $contentXml;
$webpartmanager.AddWebPart($webpart, $webpartzone, $index);
$web.Close()
$site.Close()
function Get-SPSite([string]$url) {
New-Object Microsoft.SharePoint.SPSite($url)
function Get-SPWeb([string]$url) {
$SPSite = Get-SPSite $url
return $SPSite.OpenWeb()
$SPSite.Dispose()
main
I was investigating further after posting yesterday and used powershell to bind to a webpart created by the script and a webpart I created using the sharepoint interface. Then I exported all the properties and their values to two different text files and
used winmerge to compare the differences to see if there was a setting I was missing in the script or something akin to that. However when I did the comparison the only differences between the two were the following values: Title, Description, PartOrder, ID,
StorageKey, EffectiveTitle, DisplayTitle, ZoneIndex, ClientID, and UniqueID. All of which you would expect to be different. All other settings are exactly the same on both webparts.
I am at a complete loss as to what this issue might be.
Kindest Regards,
-Zach -
Linking two lists to create a Data Source but cannot add web part to page in SharePoint designer
All;
I created a new data source by linking two lists which created a linked Data Source. I now want to access that linked data source via insertion of a Data Source control on a web part page.
What I find is, both DATA SOURCE and DATA VIEW are inactive and unselectable.
Is there any way to get this functionality going?
Thx
Larry PexterHi Larry,
Since it is a coding UI, we need to put cursor into appropriate place so we can insert data view web part, i.e. the coding which represents the web part in to the whole coding part.
As I tested in my envrionment, if you put cursor between <ZoneTemplate> and </ZoneTemplate>, I cannot get the DATA view, even before </ZoneTemplate>. Please put it exactly before <ZoneTemplate>.
If you have modify the coding, please click save and test the issue again.
Regards,
Rebecca Tu
TechNet Community Support -
Hi Team,
I am SharePoint 2013 developer. Before asking question I would like to explain the requirement in clarity.
We are developing one O365 SharePoint online site which is having 10 different page layouts with different and some common webparts and we are reusing these page layouts by deploying a sandboxed solution which is having page layouts. These page layouts contain
filter and query to display data using some condition and predefined values. By using these layouts we have to create 100+ pages. All pages will show data according to that page name and category (if it belongs any). We have not written any code to develop
the site, everything is OOB feature.
We have used below feature/list/lib of SP Online 2013:
- Document Library
- Survey
- Calendar
- Lists
- Discussion forum library
- OOB Search feature
Now, I would like to know whether this is the right approach to reuse the page layouts. Or can we add webparts directly where the logic resides in the webparts and add them to the pages instead of page layouts?
Also how to deploy page layouts/pages from one server to another? Currently we are deploying everything as a feature using sandbox solution.
Could you please let me know the right approach to follow. I am asking this question because we are facing below issues:
- Sometime page layouts gets corrupted, showing nothing.
- All written filters/logic disappear when we open layouts in Designer
- Deployment is pain using Sandbox solution
Waiting for your reply.
Thanks in Advance,
Shifa MittalInteresting question, to which i do not know a definitive answer.
Output Caching is used to increase performance and to reduce load on the box. However since you're in the MS Cloud you don't need to worry about the latter and MS do the worrying about the former. I wouldn't be surprised if MS have updated the behaviour
for O365 and not updated the documentation. That first office.com article is using 2010 screenshots which doesn't fill me with confidence about it's continuing relevance. Don't forget that SharePoint 2013 and O365 are technically different versions and have
very different behaviour in places.
Generally i'd say not to worry, but in this case if you do find any more information i'd love to see it. -
How to add the Note board web part to a page with powershell
Hi everyone,
I've been looking around everywhere but haven't seen it explicitly mentioned.
Does anyone know how to add the Note Board web part to a Team Site page, e.g. Non-publishing site, Left Zone, First webpart in the zone in powershell?
Examples like this one http://adicodes.com/adding-web-part-to-page-with-powershell/ only talk about custom web parts uploaded from a local drive.
The example here looks good - http://spcrew.com/blogs/lists/posts/post.aspx?id=21 but is it for the Page Viewer Web Part. How would you go about getting the correct name for the note board web part and configuring it?
Many Thanks,
Ashley
function main(){
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$url = "http://sp2010dev1/sites/test1"
$OpenWeb = Get-SPWeb $url
$OpenWeb
$OpenSite = Get-SPSite $url
$file = $OpenWeb.GetFile("http://sp2010dev1/sites/test1/SitePages/test1.aspx")
$WebPartManager = $file.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
Add-PageViewerWebPart "http://sp2010dev1/sites/test1" "http://sp2010dev1/sites/test1/SitePages/test1.aspx" "Body" 0 "SPCrew Site" "sp2010dev"
$OpenWeb.Dispose()
function Add-PageViewerWebPart($SiteURL, $pageUrl, $webpartzone, $index, $title, $content)
$site = new-object Microsoft.SharePoint.SPSite($SiteURL)
$web=$site.OpenWeb()
$webpartmanager=$web.GetLimitedWebPartManager($pageUrl, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$webpart = new-object Microsoft.SharePoint.WebPartPages.PageViewerWebPart
$webpart.ChromeType = [System.Web.UI.WebControls.WebParts.PartChromeType]::TitleOnly;
$webpart.Title = $title
$webpart.ContentLink = "http://www.spcrew.com";
$webpartmanager.AddWebPart($webpart, $webpartzone, $index);
$web.Close()
$site.Close()
function Get-SPSite([string]$url) {
New-Object Microsoft.SharePoint.SPSite($url)
function Get-SPWeb([string]$url) {
$SPSite = Get-SPSite $url
return $SPSite.OpenWeb()
$SPSite.Dispose()Hi,
According to your post, my understanding is that you wanted to add the Note board web part to a page with PowerShell.
The name of the Note Board web part is SocialCommentWebPart.
I recommend to use the powershell code below:
$pageUrl="http://sitename/SitePages/test.aspx"
$SiteURL="http://sitename"
$site = new-object Microsoft.SharePoint.SPSite($SiteURL)
$web=$site.OpenWeb()
$webpartmanager=$web.GetLimitedWebPartManager($pageUrl, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$webpart = new-object Microsoft.SharePoint.Portal.WebControls.SocialCommentWebPart
$webpart.title="Note Board"
$webpartmanager.AddWebPart($webpart, "MiddleZone", 0);
$web.Close()
Then the Note board web part will be added to the page.
Best Regards,
Linda Li
Linda Li
TechNet Community Support -
Custom master page branding is missing buttons to add Web Parts
I've created a custom master page which does not display the "add" or "cancel" buttons when adding web parts to the page. These elements are controlled by CSS tags such as: .ms-wpadder, .ms-wpadder-cell, .ms-wpadder-buttonArea, .ms-wpadder-zoneArea, #s4-ribbonrow
among others. I have attached a screenshot on my SkyDrive account
SharePoint Master Page Screenshot
which displays the web part objects but not the buttons to add them to your page. The cells of the #s4-ribbonrow are red .ms-wpadder-cell have been colored orange for display purposes. Here is some code I am experimenting with to solve the problem
#s4-ribbonrow{background-color:red !important; padding-bottom:50px !important;min-height: 43px; max-height:200px; overflow-y: hidden;}
.ms-wpadder-buttonArea .ms-wpadder-zoneArea{padding-bottom:50px; background-color:aqua;}
.ms-wpadder-cell{min-height:220px !important; background-color:orange;}
.ms-wpadder{padding-bottom:50px !important;}
#RibbonContainer{background-color:transparent;}
body #s4-ribboncont{background-image:none; padding-top:150px;}
Alex Dove - MA, MCP, SharePoint certified developerHi Pivotal,
I think you use other style, because I apply your style on v4.master but this hide all ribbon
panels, anyway I think your issue related with
body #s4-ribboncont
padding-top: 150px;
Try to decrease or remove padding-top.
Hope that helps a little
Regards,
Senior Sharepoint Developer [email protected] -
I am working on an enterprise wiki site collection, and when contributor users try to add web parts they will get the following error:-
A Web Part or Web Form Control on this Page cannot be displayed or imported. You don't have Add and Customize Pages permissions required to perform this action.
So I granted the Contribute Permission level an extra permission which is “Add and Customize Pages”. Now contributors will be able to add/edit/delete
web parts. But they will have extra permissions that I do not want them to have , such as changing the design and customize some page layouts, also they can access the site settings and create site columns !!.
So my question is basically if there is another way to allow users with contribute permission to be able to add web parts without granting any extra permission. In other words to treat adding web parts as normal content such as image, Text ,tables ?
ThanksI dont think so.
http://technet.microsoft.com/en-us/library/cc288074%28v=office.14%29.aspx
Add and Customize Pages
Add, change, or delete HTML pages or Web Part pages, and edit the Web site by using a Windows SharePoint Services-compatible editor.
View Items, Browse Directories, View Pages, Open
Design, Full Control
If this helped you resolve your issue, please mark it Answered. You can reach me through http://freeit-support.com/
so there are not any workarounds or any custom settings which i can use to implement any of these:-
- To force Contributor users to add web parts without granting them "Add and Customize Pages"
- If i grant them "Add and customize Pages" permission, to stop the ability to access the site settings ?
Please can any one advice on this , as it is causing a lot of confusion,,, and i can not live with the face that Contributor users can access and modify site settings. the other approach will be is that i will stop using web parts. but one of our main reasons
we decide to use SharePoint is the ability to add web parts, especially the Visio & Excel web access web. thanks in advance for any advice .. -
SP 2013 - Use PowerShell to Add a Custom Web Part to a Page
Hello Community,
I need to add a custom web part to a page using PowerShell - has anyone done this and if so please provide guidance and code examples.
Thanks!
Tom
Tom Molskow - Senior SharePoint Architect - Microsoft Community Contributor 2011 and 2012 Award -
Linked-In - SharePoint GypsyBTW, here is my current code:
#$web= Get-SPWeb -Identity "http://c4968397007/sites/BRE"
$Url = "http://c4968397007/sites/BRE"
$pageUrl = "/SitePages/Home"
$webpartzone = 2
$index = 0
$fileName = "wp_DistrictHomePage_VisualWebPart1.webpart"
$web = Get-SPWeb $Url
$web.AllowUnsafeUpdates=$true
$webPartGallery = $web.Lists["Web Part Gallery"]
Write-Host "Searching webpart $fileName in web part gallery"
if($webPartGallery -eq $null)
Write-Host("Unable to retrieve Webpartgallery");
$webpart = $null;
$webpart=$webPartGallery.Items | ? { $_.Title -eq $fileName}
if($webpart -eq $null) {
Write-Host("Unable to retrieve webpart: $fileName") -ForegroundColor Red
else {
Write-Host("----------Adding Webpart--------")-ForegroundColor Yellow
$webpartmanager=$web.GetLimitedWebPartManager($pageUrl, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$errorMsg = "";
$xmlReader = New-Object System.Xml.XmlTextReader($webpart.File.OpenBinaryStream());
$webpart = $webpartmanager.ImportWebPart($xmlReader,[ref]"Error")
$webpartmanager.AddWebPart($webpart, $webpartzone, $index);
Write-Host("Webpart is added successfully") -ForegroundColor Green ;
$SiteURL =$Url
#---------------Test Page----------------------------
$PageName="Test.aspx"
$page=$web.lists["Pages"].Items | ? {$_.Name -eq $PageName}
$page.File.CheckOut();
Add-WebPartToPage "$SiteURL/Pages/$PageName" "Header" 0 "My Custom WebPart"
$page.File.CheckIn("Added Web part to a page");
$page.File.Approve("Added Web part to a page");
Tom Molskow - Senior SharePoint Architect - Microsoft Community Contributor 2011 and 2012 Award -
Linked-In - SharePoint Gypsy
Maybe you are looking for
-
W520 hangs on Windows 7 Pro x64 installation, cannot boot live CD
Hi Everyone! I decided to reach out to the community for some intelligence that I have not been able to obtain elsewhere. Here's my story in details in case someone can find a break on any of them ... I purchased my W520 in November, 2011 with 1 yea
-
After the update to Android 5.0.1 on my Galaxy Note 4, my Galaxy Gear S will not install apps, I get an error message that says "Installation Failed. Try Later. (WO:WO:-1002). I am glad it was a free app I was trying to install (I tried a couple of d
-
sir i cant update my macbook to mac os x 10.5.8 . it hangs wile updating and i am looking for a better update . knidly reply thanks
-
Is PSA 3.0 SE an upgrade to PSA 2.0?
I currently have the full version (not starter) of Adobe Photoshop Album, and am wondering if Adobe Photoshop Album 3.0 Start Edition is an upgrade .... or exactly what it is. There is not full version of PSA 3.0, only the free starter addition.... s
-
Issue with Sun Java Web Proxy Server
I am using Sun Java Web Proxy Server to test my webservice in https mode.(SSL mode).When i test the webservice in http mode,its working fine,but when I test it in SSL mode ,it is giving the following error: Unable to tunnel through localhost:8082. Pr