Archive

Archive for the ‘Master Pages’ Category

Be careful when editing the application.master page

29 October 2007 Toby 9 comments

Here’s an odd one.

We had customized our master pages by adding in the Search WebPart, so we could customize some of the parameters

We changed the following:

<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server"></asp:ContentPlaceHolder>

To the following:

<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">
<SPSWC:SearchBoxEx webpart="true" runat="server" __webpartid="{2883947B-2B5C-4A56-92B3-33B7383F7C0D}" id="SearchBoxEx1"><WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
  <Title />
  <FrameType>None</FrameType>
  <Description>Used to search document and items.</Description>
  <IsIncluded>true</IsIncluded>
  <ZoneID>ImportedPartZone</ZoneID>
  <PartOrder>0</PartOrder>
  <FrameState>Normal</FrameState>
  <Height />
  <Width />
  <AllowRemove>true</AllowRemove>
  <AllowZoneChange>true</AllowZoneChange>
  <AllowMinimize>true</AllowMinimize>
  <AllowConnect>true</AllowConnect>
  <AllowEdit>true</AllowEdit>
  <AllowHide>true</AllowHide>
  <IsVisible>true</IsVisible>
  <DetailLink />
  <HelpLink />
  <HelpMode>Modeless</HelpMode>
  <Dir>Default</Dir>
  <PartImageSmall />
  <MissingAssembly>Cannot import this Web Part.</MissingAssembly>
  <PartImageLarge />
  <IsIncludedFilter />
  <ExportControlledProperties>true</ExportControlledProperties>
  <ConnectionID>00000000-0000-0000-0000-000000000000</ConnectionID>
  <ID>g_455588d4_92a9_484e_9273_9221d7a9a97f</ID>
  <GoImageUrl xmlns="urn:schemas-microsoft-com:SearchBoxEx">/_layouts/images/gosearch.gif</GoImageUrl>
  <GoImageUrlRTL xmlns="urn:schemas-microsoft-com:SearchBoxEx">/_layouts/images/goRTL.gif</GoImageUrlRTL>
  <GoImageActiveUrl xmlns="urn:schemas-microsoft-com:SearchBoxEx">/_layouts/images/gosearch.gif</GoImageActiveUrl>
  <GoImageActiveUrlRTL xmlns="urn:schemas-microsoft-com:SearchBoxEx">/_layouts/images/goRTL.gif</GoImageActiveUrlRTL>
  <DropDownModeEx xmlns="urn:schemas-microsoft-com:SearchBoxEx">ShowDD_DefaultContextual</DropDownModeEx>
  <AdvancedSearchPageURL xmlns="urn:schemas-microsoft-com:SearchBoxEx">/SearchCenter/Pages/advanced.aspx</AdvancedSearchPageURL>
  <SearchResultPageURL xmlns="urn:schemas-microsoft-com:SearchBoxEx">/SearchCenter/Pages/results.aspx</SearchResultPageURL>
  <ScopeDisplayGroupName xmlns="urn:schemas-microsoft-com:SearchBoxEx">Search Dropdown</ScopeDisplayGroupName>
  <RegisterStyles xmlns="urn:schemas-microsoft-com:SearchBoxEx">true</RegisterStyles>
  <ShouldTakeFocusIfEmpty xmlns="urn:schemas-microsoft-com:SearchBoxEx">false</ShouldTakeFocusIfEmpty>
                </WebPart>
</SPSWC:SearchBoxEx>
</asp:ContentPlaceHolder>

We did this in all our master pages including the application.master page.

All was working fine until we tried to delete a column in a list and we go the “Unknown Error” message and the column wasn’t deleted.

The following error message was be ing logged

Application error when access /_layouts/mngfield.aspx, Error=Unable to validate data.   at System.Web.Configuration.MachineKeySection.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength)     at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) 

After of a month or so of investigation with Microsoft support, we discovered that the Search Webpart was causing the problem in the application.master page and causing a conflict in one of the application pages in the “Layouts” directory, specifically the mngfield.aspx page.

We have removed the Search WebPart from the application.master page and all seems to be working fine.

Categories: Bugs, Master Pages, Search

Using a custom master page in a site definition

30 April 2007 Toby 4 comments

UPDATE

Don’t use the Sharepoint Solution Generator, so far we have not been able to upgrade the site definitions through a solution without it killing existing sites based on the site definition. 

I have seen many different ways of doing this, but I found the following method seemed to work for me, using the “SharePoint Extensions for Visual Studio 2005″ and the “SharePoint Solutions Generator

  • Use the “SharePoint Solution Generator” to create a site definition project.
  • Open the project and add your custom master page to the “Site Definition” folder

  • Open up “onet.xml”
  • Add the following node to the “ListTemplates” section

<ListTemplate Name=”mplibDisplayName=”$Resources:MasterPageGallery;Description=”$Resources:global_onet_mplib_desc;SetupPath=”global\lists\mplibType=”116BaseType=”1Path=”GLOBALHidden=”TRUEHiddenList=”TRUENoCrawl=”TRUEUnique=”TRUECatalog=”TRUEOnQuickLaunch=”FALSESecurityBits=”11AllowDeletion=”FALSEAllowEveryoneViewItems=”TRUEImage=”/_layouts/images/itdl.gifAlwaysIncludeContent=”TRUEDocumentTemplate=”100” />

  • Add the “MasterUrl” attribute to the “Configuration” node with a value of “_catalogs/masterpage/project.master”, where project.master is the name of your custom master page. This means all the pages using the “~masterurl/default.master” token will use the URL defined to point to your custom master page

<Configuration ID=”0Name=”DefaultMasterUrl=”_catalogs/masterpage/project.master“>

  • Add a “Module” node to the Modules section of the configuration called “MasterPage” that will reference the module definition in the “Modules” section of the onet file

<Module Name=”MasterPage” />

  • Add a module definition to the “Modules” section of the onet file. This will copy the custom master page file into the master page library when the site is provisioned.

<Module Name=”MasterPageList=”116Url=”_catalogs/masterpageRootWebOnly=”FALSE“>

<File Url=”project.masterType=”GhostableInLibraryIgnoreIfAlreadyExists=”TRUE” />

</Module>

  • Save the onet file and then deploy the project into your environment using the deploy option in “SharePoint Extensions for VS 2005″
  • When you create a new site from your site definition it should now use your new master page.

Below is a screen grab of the onet.xml file with all the changes highlighted