SPFieldMultiLineText sampleField = sampleListItem.Fields["Sample"] as SPFieldMultiLineText;
string sampleText = sampleField.GetFieldValueAsText(sampleListItem["Sample"]);
Wednesday, April 22, 2009
SP2007 - How to retrieve text from an Enhanced rich text column
Saturday, April 18, 2009
SP2007 - EnableInheritance="True"
If you set Current Navigation to “Display the same navigation items as the parent site” and you don’t see the same navigation items as the parent site, you might need to add an EnableInheritance="True" attribute to the PublishingNavigation:PortalSiteMapDataSource as in this example:
<PublishingNavigation:PortalSiteMapDataSource ID="SiteMapDSWithHeadings" Runat="server"
SiteMapProvider="CurrentNavSiteMapProvider"
EnableViewState="true"
StartFromCurrentNode="true"
StartingNodeOffset="0"
ShowStartingNode="false"
TrimNonCurrentTypes="None"
EnableInheritance="True"/>
Saturday, March 28, 2009
SP2007 - How to hide a CQWP Group Header if it is Blank
By default, the CQWP Group Header displays (Blank) if the group by field is null. The desired behavior is to display nothing.
For example, add the following xsl template, SmallTextHiddenBlank, under the existing xsl template, SmallText, in the Header.xsl file in the Style Library. Then, choose the SmallTextHiddenBlank Header template in the CQWP Tool Part.
<xsl:template name="SmallTextHiddenBlank" match="*[@GroupStyle='SmallTextHiddenBlank']" mode="header">
<xsl:choose>
<xsl:when test="string-length(normalize-space(@*[name()=$Group])) = 0">
</xsl:when>
<xsl:otherwise>
<div class="groupheader item small">
<xsl:call-template name="OuterTemplate.GetGroupName">
<xsl:with-param name="GroupName" select="@*[name()=$Group]"/>
<xsl:with-param name="GroupType" select="$GroupType"/>
</xsl:call-template>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Tuesday, March 10, 2009
SP2007 - How to Programmatically Inherit Current Navigation
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
/// <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
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
Site Collection > Site Settings > Regional Settings > Time Zone