TwitterLinkedInBlog

Tuesday, March 10, 2009

SP2007 - How to Programmatically Inherit Current Navigation

Scenario: Office SharePoint Server Publishing Infrastructure is activated at the SPSite level. Office SharePoint Server Publishing is NOT activated at the SPWeb level. Attempting to inherit Current Navigation from the Parent SPWeb.

using Microsoft.SharePoint.Publishing;
  …
  PublishingWeb currentPublishingWeb = PublishingWeb.GetPublishingWeb(currentWeb);
  currentPublishingWeb.InheritCurrentNavigation = true;
  currentPublishingWeb.Update();

 // Does not work because the SPWeb is NOT a PublishingWeb:
 //if (PublishingWeb.IsPublishingWeb(currentWeb))
 //{
 //    PublishingWeb currentPublishingWeb = PublishingWeb.GetPublishingWeb(currentWeb);
 //    currentPublishingWeb.InheritCurrentNavigation = true;
 //    currentPublishingWeb.Update();
 //}
 //else
 //{
 //    currentWeb.Navigation.UseShared = true;
 //    currentWeb.Update();
 //}

Friday, February 20, 2009

SP2007 - Web Part HandleException Technique

Hide the exception message and stack trace in html comments and provides a Cancel link for the user to refresh the page:
/// <summary>
/// Clear all child controls and add an error message for display.
/// </summary>
private void HandleException(Exception ex)
{
m_ErrorHasOccurred = true;
Controls.Clear();
Controls.Add(new LiteralControl(string.Format("<!--{0}--><!--{1}-->{2}{3}",
ex.Message, ex.StackTrace,
"An error has occurred. Please contact your administrator.",
"<br/><a href='" + Page.Request.Url.ToString() + "'>Cancel</a>")));
}

Sunday, December 7, 2008

SP2007 - How to delete a site with subsites

Site Actions > Site Settings > Site Administration > Content and Structure
In the left column, move to the parent of the main site to be deleted
In the right column, choose the site to be deleted
Actions > Delete

Friday, August 22, 2008

SP2007 - Time Zone

Central Administration > Application Management > Web Application General Settings > Default Time Zone

Site Collection > Site Settings > Regional Settings > Time Zone

SP2007 - Web Part Error: One of the properties of the Web Part has an incorrect format.

Web Part Error: One of the properties of the Web Part has an incorrect format. Windows SharePoint Services cannot deserialize the Web Part. Check the format of the properties and try again.

Windows directory
%WinDir%\Temp
Administrators - Full Control
SYSTEM - Full Control
WSS_WPG - Read, Write
Network Service (for a domain controller only) - Read, Write

%WinDir%\system32\logfiles
STS Administrators - Full Control
SYSTEM - Full Control
WSS_WPG - Read, Write
Network Service (for a domain controller only) - Read, Write

SP2007 - web.config debug settings

SharePoint 2007 web.config debug settings

<configuration>
  <SharePoint>
    <SafeMode CallStack="true" />
  </SharePoint>
  <system.web>
    <customErrors mode="Off" />
    <compilation debug="true" />
  </system.web>
</configuration>

SP2007 - The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access to Temporary ASP.NET Files

"The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access to Temporary ASP.NET Files"

aspnet_regiis -ga "NT AUTHORITY\NETWORK SERVICE"