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

Similar Messages

  • 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

  • Advanced search web part issue

    hi,
     i am implementing a  advanced search web part , and in that  property restrictions, i have added  2  doument library columns [ not the site columns ]
    from my subsite in my site collection.
    but when i give some search keywords and perform   search, i am not able to get the search results in terms of documents/content.
    any extra settings do i need to do for performing advanced search
    1) Do i really need site columns to be created under the site collection , in order to be  searchable ?
    if i create a  simple document library column and cant i get it in the crawled properties section
    in the  central admin's search serv appln's  search schema section?
    pls advice

    As per my understanding you can crawl DL columns
    Can you get that document in search results page? Please check to see if the site which contains the library is included in content source.
    Could you please check site settings->Site Administration->Searchable columns, maybe the column is excluded?
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/b97a43b1-c727-4daa-a0d9-a18e53e09dd9/list-and-document-library-title-column-crawled-properties?forum=sharepointadminprevious
    Go to your Search Service Application in Central Administration.
        Click on Metadata Properties in the left navigation.
        Click on the Crawled Properties link.
        Click on the Categories link then select the SharePoint category
        Navigate the pages (next page arrow link) until you see ows_Title. Click on ows_Title.
        In the "Mappings to Metadata Properties" area of this page, ensure that the "Include values for this property in the search index" checkbox is checked, then Click OK. This checkbox is not checked by default.
        Repeat the same procedure above for your ows_Description crawled property to confirm that it is included in the index - which it should be by default.
        Start a Full Crawl 
    This will now include these crawled properties in the index and should now be available in the Managed Property which exposes them for Search.
    If this helped you resolve your issue, please mark it Answered

  • Tagged items web part issue SP 2013

    Hi,
    we have configured Content tag cloud and we have two different issues.
    1. we have configured to show the tags that are tagged under the current url by all users, but when we click on the tag, it shows all the documents that are tagged with that specific tag (from different sites), is this a known behavior.
    2. For many of the tags, we don't see the documents in the Tagged items web part (some only shows in popular within 60 days tab but not in All tab)
    We have run the full crawl and social maintenance timer job to fix some other issues earlier. I also read somewhere that we need to activate the content type syndication hub, but we already have many tags working fine. what is the relation to the content
    type syndication hub.
    Any help would be really appreciated. Thanks.

    Hi Senthil,
    #1. Yes. If we click a tag in the Tag Cloud web part, it will redirect use to the tag profile page for this tag.
    And all the items tagged by the tag will be displayed in this tag profile page.
    #2. This issue may be due to the incremental crawl miss some tagged items or tags.
    I recommend to run a full crawl and then check the results.
    Per my knowledge, it has nothing to do with the content type syndication hub.
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Setting scope in Search core result web part issue

    Hi All,
     I don't know if it is default behavior of search, But I am facing below issue.
    I created new scope which is targeted to one web app url in my server. Now when i set this scope in Search core result web part edit properties and search from default.aspx page it works fine.
    (And one more thing Location is set to Local FAST Search Results)
    But if I type new search keyword on search result.aspx page its passing extra url parameter as &u= with another site and I am not getting any result for my keyword.
    (if i remove & u= from my url it again works)
    Any idea about this? Am i missing any setting?
    Regards,
    Satish
    Thanks, Satish

    On the search results page, there is a search web part
    you need to make setting to that search webpart so that it redirects to same page without and extra quote. 
    It will mainly a trial and test for you
    If this helped you resolve your issue, please mark it Answered

  • SharePoint Document Library Web Part issue

    i came across with a strange issue. if i am putting document library web part and below task webpart or calender webpart then if i am clicking on New button of doc library it is popping up the task list menu. please refer the below snapshot. 
    please help me to fix this or it seems its a Bug in sharepoint online. 
    can any one please confirm or suggest?

    Hi,
    I have done a test in my SharePoint 2013 online and I got the same issue with you.
    When I put document library web part  below task webpart or any other list webpart, then I click on New button of doc library it is popping up the list's content type.
    There is no OOTB method to solve the issue.
    Best Regards,
    Lisa Chen
    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]
    Lisa Chen
    TechNet Community Support

  • Broken Web Part Issue

    Hi..
    We Restored Content Database backup from SharePoint 2010 to SharePoint 2013 environment and its restored correctly, but when we browsed the site, we are getting 
    Could not load file or assembly  or one of its dependencies. The system cannot find the file specified.
    But we don't have code for Custom Web Parts or wsp. so we tried by Web Part Maintenance Mode ( ?Contents=1), but didnot find the exact broken web Part Title..
    So how to resolve the above issue.
    Ravindranath

    try checking ULS logs woith corelation ID:
    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\LOGS
    also try these links:
    http://stackoverflow.com/questions/1265505/sharepoint-could-not-load-file-or-assembly-the-system-cannot-find-the-file-sp
    http://sharepoint.stackexchange.com/questions/69897/could-not-load-file-or-assembly-or-one-of-its-dependencies-the-system-cannot-fi
    http://www.sharepointpals.com/post/Failed-to-load-receiver-assembly-SystemIOFileNotFoundException-Could-not-load-file-or-assembly-or-one-of-its-dependencies-on-Feature-Receiver-in-SharePoint-2013
    Please mark answer as correct if it is correct else vote for it if you find it useful Happy SharePointing

  • Web-part issue after migrating from 2010 to 2013

    Hello all
    Correct me if I am posting this question in the wrong section.
    The background is: Migrating and Upgrading SP2010 to SP2013. I did it, and alot of it works, as it should, though I have one issue.
    I did deploy all the solutions to both the 14 and 15 hive, and activated all the propper features. Now, I have one web-part which breaks down. It is a Web-part that communicate with a SAP endpoint, to retrive some data and show dem. The Web-part work fine in
    the 2010 environment.
    As soon as I enter the site where the Web-part is placed in, I am being redirected to the "Maintanence Web-part, error message". If I delete the Web-part I can access the site with no errors. The code works fine in 2010. 
    The error I am getting is "value cannot be null".
    Unexpected System.ArgumentNullException: Value cannot be null. Parameter name: uriString at System.Uri..ctor(String uriString) at Microsoft.SharePoint.SPSite..ctor(String requestUrl) at MyWebPart.Core.ListConfiguration.<>c__DisplayClass1.<GetKeyValue>b__0()
    at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.<RunWithElevatedPrivileges>b__3() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback
    secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at MyWebPart.Core.ListConfiguration.GetKeyValue(String key) at MyWebPart.OrderCatalog.OrderCatalogUserControl.FillFilterBoxes() ... 438bb29c-c202-3049-9aab-e895c85176d5
    Unexpected ...at MyWebPart.OrderCatalog.OrderCatalogControl.Page_Load(Object sender, EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.AddedControl(Control control, Int32 index) at MyWebPart.OrderCatalog.OrderCatalog.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 includeStagesB... 438bb29c-c202-3049-9aab-e895c85176d5
    Unexpected ...eforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 438bb29c-c202-3049-9aab-e895c85176d5

    No, I did not migrate the content from 2010 web-config to the 2013 server. This is something I will take a look at, to see if there are some missing points in the config-file of 2013.
    And just to be sure, when we are talking about the config file, it is the one who is associated with the Web-applikation? So, IIS --> WebApp --> Explorer --> and that web.config?

  • Can I get the value for community site's What's Happening web part with Powershell?

    I need to generate some statistic reports for our SP2013 community site. Some of figures I need are "no. of discussion", "no. of replied" and "no. of members" which are already listed in the "What's Happening" web
    part.
    Can I directly get this counters with PowerShell instead of calculating from "Discussion Board List"?

    Hi,
    As we can see from “Site Contents” page, the data displayed in the “What’s happening” stores in these two lists “Community Members” and “Discussion List”, if you want to retrieve
    the data using PowerShell, we will need to access these two lists directly.
    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

  • Which one is the Right Approach - Re Using Page Layouts or adding Web parts directly to pages instead of page layouts in SP 2013 online site ?

    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 Mittal

    Interesting 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.

  • Slideshow web part issue

    A user has ntcied that the Slideshow webpart is taking her png images and converting them to jpg images.  The problem is that the jpeg text does not render will and the user is asking if there is a way that the slide show image converted can be skipped
    or manipulated in souch that the it does change or create a new jpg image when it encounters a png image.

    Hi Michel,
    Please share OS, IE and Office version. Also check this behavior with different browsers and share your results, thanks
    Regards,
    Pratik Vyas | SharePoint Consultant |
    http://sharepointpratik.blogspot.com
    Posting is provided AS IS with no warranties, and confers no rights
    Please remember to click Mark As Answer if a post solves your problem or
    Vote As Helpful if it was useful.

  • 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

  • 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 Gypsy

    BTW, 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

  • Updating List View Web Part property in page

    I have a List View web part (In the page > Add web part > App > document library name). I need to update the TitleUrl property of this web part through C# code.
    The SaveChanges() method below works for my visual web parts, but not for the List view webpart. I get an error saying: Exception has been thrown by the target of an invocation
    webpartManager = myPage.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);webPart.TitleUrl = titleURL;webpartManager.SaveChanges(webPart);
    I did a casting as below
    XsltListViewWebPart listViewWebPart = (XsltListViewWebPart)webPart;listViewWebPart.TitleUrl = titleURL;webpartManager.SaveChanges(listViewWebPart);
    (Please note that casting to ListViewWebpart instead of the XsltListViewWebpart gives a invalid cast exception, which is the reason why I cast it to XsltListViewWebpart) 
    But I get the error at SaveChanges() method.
    An exception of type 'System.Reflection.TargetInvocationException' occurred in Microsoft.SharePoint.dll but was not handled in user code
    The error description is as below
    >    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[]
    > arguments, Signature sig, Boolean constructor)    at
    > System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
    > Object[] parameters, Object[] arguments)    at
    > System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
    > invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)  
    > at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[]
    > index)    at
    > Microsoft.SharePoint.WebPartPages.BinaryWebPartSerializer.DoesPersonalizedPropertValueMatchDefaultValue(SPPersonalizablePropertyEntry
    > spPersonalizablePropertyEntry, Object value, Control defaultControl)  
    > at
    > Microsoft.SharePoint.WebPartPages.BinaryWebPartSerializer.Serialize(PersonalizationScope
    > scope, BinaryWebPartSerializerFlag binaryWebPartSerializerFlags,
    > BinaryWebPartSerializerWriter writer)    at
    > Microsoft.SharePoint.WebPartPages.BinaryWebPartSerializer.Serialize(SerializationMode
    > mode, BinaryWebPartSerializerFlag binaryWebPartSerializerFlags,
    > SPSerializationBinderBase serializationBinder,
    > BinaryWebPartSerializerWriter writer)    at
    > Microsoft.SharePoint.WebPartPages.BinaryWebPartSerializer.Serialize(SerializationMode
    > mode, BinaryWebPartSerializerFlag binaryWebPartSerializerFlags,
    > SPSerializationBinderBase serializationBinder)    at
    > Microsoft.SharePoint.WebPartPages.SPWebPartManager.SaveChangesCore(SPLayoutProperties
    > layoutProperties, Boolean httpGet, Boolean saveCompressed, Boolean
    > skipRightsCheck, Boolean skipSafeAgainstScriptCheck, WebPartTypeInfo&
    > newTypeId, Byte[]& newAllUsersProperties, Byte[]&
    > newPerUserProperties, String[]& newLinks)    at
    > Microsoft.SharePoint.WebPartPages.SPWebPartManager.SaveChangesInternal(SPLayoutProperties
    > layoutProperties, Boolean skipRightsCheck, Boolean
    > skipSafeAgainstScriptCheck)    at
    > Microsoft.SharePoint.WebPartPages.SPWebPartManager.SaveChanges(Guid
    > storageKey)    at
    > Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.SaveChanges(WebPart
    > webPart)    at
    > WSP.ABC.ABC.ABCWindow.<>c__DisplayClass5.<ChangeWebPartProperties>b__4()
    > at
    > Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.<RunWithElevatedPrivileges>b__3()
    > at
    > Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated
    > secureCode)
    Tried casting back as below
    webpartManager.SaveChanges((System.Web.UI.WebControls.WebParts.WebPart)listViewWebPart)
    but still the error at SaveChange() is there.
    AllowUnsafeUpdates is set to true within this block and code runs in elevated privileges.

    Hi Ahamed,
    According to your description, there is an issue when you try to update the TitleUrl property of a List View Web Part.
    For a better troubleshooting, I suggest you do as the followings:
    1. Debug your code step by step and make sure every object and variable is valid.
    2. Here is a code snippet about update web part property programmatically:
    SPWeb web = SPContext.Current.Web;
    SPFile file = web.GetFile(HttpContext.Current.Request.Url.ToString());
    SPLimitedWebPartManager manager = file.GetLimitedWebPartManager(PersonalizationScope.User);
    System.Web.UI.WebControls.WebParts.WebPart webPart = manager.WebParts[this.ID];
    ((UpdateMeWebPart)webPart).Message = “Test”;
    try
    web.AllowUnsafeUpdates = true;
    manager.SaveChanges(webPart);
    finally
    web.AllowUnsafeUpdates = false;
    Here is a detailed article for your reference:
    http://jeremyknight.wordpress.com/2010/11/12/programmatically-update-web-part-properties/
    Best Regards
    Zhengyu Guo
    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 developer

    Hi 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]

Maybe you are looking for