Unable to display this Web Part. SharePoint 2010 Data View Web Part issue.

Problem:

On our intranet, we have been constantly getting the following errors on pages that contains a Data View Web Part. Although I said constantly, it doesn’t mean that the error shows on a page all the time. It meant that a page sometimes works sometimes doesn’t. But if it doesn’t, it will show that error message. The inconsistant of the error makes it more difficult to debug and the log file wasn’t helpful either.

Data View Web Part Error

After searching online, a few people has had the same problem. Someone said it had something to do with a SharePoint Update and suggested to install a hotfix, but we didn’t have that update installed so we didn’t want to try the hotfix. Another post mentioned that adding the “AllowPersonalization” property to a web part zone should fix the problem. However, it didn’t say how to add this property.

Solution:

Open up the root site in SharePoint Designer. From the left Navigation pane, choose Page Layouts. I had a custom Page Layout used by those pages that displays the Data View Web Part, so I opened that page layout. Follow the prompt and check it out. Click the “Advanced Mode” button on the top ribbon. In your code, search for “WebPartPages:WebPartZone” and inside that tag, add AllowPersonalization=”true”.

For example:

<WebPartPages:WebPartZone id="g_9973D18452754B25AAF6B1DBDC75CF6A" runat="server" AllowPersonalization="true" title="Box 1"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

After editing the page layout, make sure to check in and publish it.

Advertisements

Create a custom HTTP404 rediect page in SharePoint 2010

By default, SharePoint takes you to its own 404 NOT FOUND page if you enter an Url which does not exist in the site.

My client has requested to display a 404 Not Found page with the custome master page and page layout style. After a few searches, some articles are found. Chaks’ and Ritu’s ones were particular helpful.

Default SharePoint 404 error pages are stored at this location:

14\TEMPLATE\LAYOUTS\1033\ERRORV4.html
14\TEMPLATE\LAYOUTS\1033\sps404.html

1. Create a error page on the site that has the publishing page layout and custom master page. I created a page called customError.aspx under the root site collection under the Pages folder.

2. Make a copy of sps404.html and name it custom404.html. Place it in the same location as sps404.html

3. Open custom404.html. Change the URL inside STSNavigate to your customError.aspx page url

customError

4. The next step is to set custom404.html as the 404 redirection page for your specific web application. we are accomplishing this by creating a custom404 feature and as the feature activates, it sets the FileNotFoundPage to the custom404.html. custom404.html then redirects the page to customError.aspx page

Open Visual Studio, create a new project, choose Empty SharePoint Project and change to .Net Framework 3.5. Name the project “PageNotFound”

Choose Deploy as a farm solution

Right click on Features, Add Feature, change the Scope to Site.

Right click on Feature1.feature, Add Event Receiver.

Open the EventReceiver.cs file, add this line above the namespace.

using Microsoft.SharePoint.Administration;

Paste the following code inside public class.

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
      if (properties != null)
      {
        SPSite currentSite = (SPSite)properties.Feature.Parent;
        SPWebApplication webApplication = currentSite.WebApplication;
         webApplication.FileNotFoundPage = "custom404.html";
         webApplication.Update();
      }
}

Right click on the project and Deploy.

Now if you go to a incorrect page, you will be redirected to your custom error page.

Reference:
http://blog.mastykarz.nl/sharepoint-2010-page-not-found-404/
http://chakkaradeep.com/index.php/customizing-the-404-redirection-in-sharepoint/
http://ritutechworld.blogspot.co.nz/2010/06/custom-error-page-in-sharepoint-2010.html
http://microsoftechies.wordpress.com/2012/10/08/error-occurred-in-deployment-step-activate-features-unable-to-cast-object-of-type-microsoft-sharepoint-spweb-to-type-microsoft-sharepoint-spsite/

Unexpected error when change page layouts

Problem:

Recently, our intranet has been renamed from gw to g10. With this change, some pages receives an unexpected error when changing the page layout.

Unexpected Error

I opened the site in SPD and tried “Detach from Page Layout”, threw the following error

 

 

question

After searching on the net, this article talked about the same problem and provided some power shell code to solve it. There were some drawbacks of this solution discussed in the comments section. So I didn’t take this approach. Another article really helped me. Thanks to the person who shared the problem and the solution.

Solution:

  1. Open the site which contains the page that had error in SPD.
  2. Go to All Files ->Pages->highlight the page that didn’t work.
  3. From the top ribbon, select Export File. Save to a location where you can find later on.
  4. Right click on the exported file and open in notepad.
  5. Ctrl + F and search for “_catalogs/masterpage/DefaultLayout.aspx”. You should only find one result and notice that link pointed to the wrong domain.
  6. Change the domain to your current correct domain and Save.
  7. Copy the file back to SPD, overwrite the existing one.
  8. Go back to the browser and change a page layout. It works!

 

Page Layout dropdown is not showing on edit mode

When I edit a page on a publishing site, I don’t see the dropdown list when I click on the Page Layout button from the ribbon. After searching on Google, I found two possibilities:

  • Don’t have enough permission
  •  SharePoint ribbon tries to load unexisting content and thus errors and cannot show the dropdown.

I checked my permission and got full control. Also noticed that for users who don’t have enough permission will simply have the Page Layout button greyed out. But for me, the button was still clickable, just no dropdown.

Found out that when the site was copied across from another site using 3rd party software, my customized content type didn’t get copied across. Therefore, its associated page layout couldn’t find the content type.

So I created the content type in SharePoint Designer:

  1. In the Navigation Pane, click “Content Types”
  2. From the ribbon, in the New section, choose Content Type
  3. Enter Name, Description.
  4. Parent content type from: Publishing Content Types
  5. Parent content type: Page
  6. Create a new group, e.g. My Custom Group
  7. Click OK, and you are finished with creating a content type in SPD.
  8. Go to the browser, Site Actions->Site Settings->Galleries->Master pages and page layouts->Select the page layout and Edit Properties
  9. Content Type: Page Layout
  10. Associated Content Type: Content Type Group: choose the group you created in step 6 Content Type Name: choose the content type you created in step 3
  11. Save and done!