<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>Chris: Geek Guy &#187; sharepoint</title>
	<atom:link href="http://chris.gg/tag/sharepoint/feed/" rel="self" type="application/rss+xml" />
	<link>http://chris.gg</link>
	<description>Tech news and other stuff from a UK-based web developer and all-round geek</description>
	<lastBuildDate>Tue, 06 Dec 2011 19:40:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Display filename instead of document title in SharePoint search</title>
		<link>http://chris.gg/2011/06/display-filename-instead-of-document-title-in-sharepoint-search/</link>
		<comments>http://chris.gg/2011/06/display-filename-instead-of-document-title-in-sharepoint-search/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 16:22:14 +0000</pubDate>
		<dc:creator>Chris Barnes</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[filename]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[title]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xsl]]></category>
		<category><![CDATA[xslt]]></category>
		<guid isPermaLink="false">http://chris.gg/?p=844</guid>
		<description><![CDATA[My employer has been using SharePoint for a number of years now, and it&#8217;s recently come to light that people haven&#8217;t always been putting meaningful information in the Document Title field. It seems that if this field is left blank, it will default to the document filename, but a lot of our documents have incorrect [...]]]></description>
			<content:encoded><![CDATA[<p>My employer has been using SharePoint for a number of years now, and it&#8217;s recently come to light that people haven&#8217;t always been putting meaningful information in the Document Title field. It seems that if this field is left blank, it will default to the document filename, but a lot of our documents have incorrect titles. e.g. if they have been based on a template or another document.</p>
<p>Clearly the best solution is to educate users to use the Title field properly for newly-created documents (see <a href="http://amatterofdegree.typepad.com/a_matter_of_degree/2007/03/title_vs_name_i.html">Title vs Name</a>), and also to update all existing documents, but it&#8217;s a big task and for now we have opted for the&#8221;quick fix&#8221; of showing the document filename in search results. Here&#8217;s how you do it:</p>
<ul>
<li>Ensure that the <strong>IsDocument </strong>managed property is set for use within scopes:
<ul>
<li>Browse to Central Administration</li>
<li>Click on your Shared Service Provider</li>
<li>Click <strong>Search settings</strong></li>
<li>Click <strong>Metadata property mappings</strong></li>
<li>Find the <strong>IsDocument </strong>property and set <strong>Use in scope</strong> to <strong>True</strong></li>
<li>Click <strong>OK</strong></li>
</ul>
</li>
<li>Edit the page and modify the <strong>Search Core</strong> web part</li>
<li>Under <strong>Results Query Options</strong>, edit the <strong>Selected Columns </strong>property to include Filename:<br />
<em>&lt;Column Name=&#8221;Filename&#8221;/&gt;<br />
<span style="font-style: normal;">(it doesn&#8217;t matter where as long as it is between <em><strong>&lt;Columns&gt;</strong></em> and <em>&lt;/Columns&gt;</em>, and obviously not halfway through another <strong><em>&lt;Column&gt;</em></strong> tag)</span></em></li>
</ul>
<ul>
<li>Find the following line (it should be in the <strong>Result</strong> template):<br />
<strong><em>&lt;xsl:variable name=&#8221;id&#8221; select=&#8221;id&#8221;/&gt;</em></strong></li>
<li>Underneath it, add the following two lines:<br />
<strong><em>&lt;xsl:variable name=&#8221;filename&#8221; select=&#8221;filename&#8221;/&gt;<br />
<strong><em>&lt;xsl:variable name=&#8221;isdocument&#8221; select=&#8221;isdocument&#8221;/&gt;</em></strong> </em></strong></li>
<li>A few lines down, replace the code starting with <strong>&lt;span class=&#8221;srch-Title&#8221;&gt;</strong> and ending in<strong>&lt;/span&gt;</strong> with the following:<br />
<em><strong> &lt;span class=&#8221;srch-Title&#8221;&gt;</strong><br />
<strong> &lt;a href=&#8221;{$url}&#8221; id=&#8221;{concat(&#8216;CSR_&#8217;,$id)}&#8221; title=&#8221;{$url}&#8221;&gt;</strong><br />
<strong> &lt;xsl:if test=&#8221;$isdocument &amp;#61; 1&#8243;&gt;</strong><br />
<strong> &lt;xsl:value-of select=&#8221;filename&#8221;/&gt;</strong><br />
<strong> &lt;/xsl:if&gt;</strong><br />
<strong> &lt;xsl:if test=&#8221;$isdocument &amp;#61; 0&#8243;&gt;</strong><br />
<strong> &lt;xsl:choose&gt;</strong><br />
<strong> &lt;xsl:when test=&#8221;hithighlightedproperties/HHTitle[. != '']&#8220;&gt;</strong><br />
<strong> &lt;xsl:call-template name=&#8221;HitHighlighting&#8221;&gt;</strong><br />
<strong> &lt;xsl:with-param name=&#8221;hh&#8221; select=&#8221;hithighlightedproperties/HHTitle&#8221; /&gt;</strong><br />
<strong> &lt;/xsl:call-template&gt;</strong><br />
<strong> &lt;/xsl:when&gt;</strong><br />
<strong> &lt;xsl:otherwise&gt;&lt;xsl:value-of select=&#8221;title&#8221;/&gt;&lt;/xsl:otherwise&gt;</strong><br />
<strong> &lt;/xsl:choose&gt;</strong><br />
<strong> &lt;/xsl:if&gt;</strong><br />
<strong> &lt;/a&gt;</strong><br />
<strong> &lt;br/&gt;</strong><br />
<strong> &lt;/span&gt;</strong></em><br />
<strong></strong></li>
</ul>
<p>I found this tip on the <a href="http://social.technet.microsoft.com/Forums/en/sharepointsearch/thread/c2ec4fc2-e04c-453c-8035-4f334f062d05">TechNet forums</a>, although it didn&#8217;t work as-is because the author had forgotten to declare the <em>isdocument</em> variable. It has been tested in MOSS 2007 but will possibly also work in SharePoint 2010. If desired, you could easily tweak the XSL above to show the document title as well as the filename.</p>
<p>There&#8217;s no easy way of changing the <strong>OSSSearchResults.aspx</strong> page that appears when you do a &#8220;This Site&#8221; search, and even if you do, it&#8217;s unsupported and any changes will most likely be lost next time you install a MOSS service pack. If you have ISAPI_Rewrite installed, as we do, you can easily redirect site searches to the Search Center using this line:</p>
<p><strong><em> RewriteRule ^(.*)OSSSearchResults.aspx(.*)$ /SearchCenter/Pages/results.aspx$2 [I,L,RP]</em></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://chris.gg/2011/06/display-filename-instead-of-document-title-in-sharepoint-search/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>&#8220;Cannot save the property settings for this Web Part&#8221; error when using SmartPart in SharePoint</title>
		<link>http://chris.gg/2010/12/cannot-save-the-property-settings-for-this-web-part-error-when-using-smartpart-in-sharepoint/</link>
		<comments>http://chris.gg/2010/12/cannot-save-the-property-settings-for-this-web-part-error-when-using-smartpart-in-sharepoint/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 12:49:17 +0000</pubDate>
		<dc:creator>Chris Barnes</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Hints & Tips]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[smartpart]]></category>
		<category><![CDATA[web part]]></category>
		<guid isPermaLink="false">http://chris.gg/?p=820</guid>
		<description><![CDATA[I recently deployed a custom user control using SmartPart on SharePoint 2007, and although everything else seemed to work fine, I came across the following error when trying to edit the properties (in my case, the chrome type and width): Cannot save the property settings for this Web Part. Exception occurred. (Exception from HRESULT: 0&#215;80020009 (DISP_E_EXCEPTION)) [...]]]></description>
			<content:encoded><![CDATA[<p>I recently deployed a custom user control using <a href="http://chris.gg/2010/02/deploy-asp-net-web-user-controls-on-sharepoint-using-smartpart/">SmartPart</a> on SharePoint 2007, and although everything else seemed to work fine, I came across the following error when trying to edit the properties (in my case, the chrome type and width):</p>
<blockquote style="text-align: left;"><p><strong><span style="color: #ff0000;">Cannot save the property settings for this Web Part. Exception occurred. (Exception from HRESULT: 0&#215;80020009 (DISP_E_EXCEPTION))</span></strong></p></blockquote>
<p>I managed to resolve this, thanks to an <a href="http://social.msdn.microsoft.com/forums/en-US/sharepointdevelopment/thread/26f50a1f-5cf9-4e28-a2ca-3f63621c34a4">MSDN forum post</a>, by changing one of my lines of code:</p>
<blockquote style="text-align: left;"><p><strong></strong><strong>using (SPSite oSiteCollection = SPContext.Current.Site)</strong></p></blockquote>
<p>to the slightly more long-winded:</p>
<blockquote style="text-align: left;"><p><strong></strong><strong>using (SPSite oSiteCollection = new SPSite(SPContext.Current.Site.ID))</strong></p></blockquote>
<p>I&#8217;m not sure why using SPContext.Current.Site directly (versus creating a new SPSite object) causes this behaviour, but at least it&#8217;s a simple fix.</p>
]]></content:encoded>
			<wfw:commentRss>http://chris.gg/2010/12/cannot-save-the-property-settings-for-this-web-part-error-when-using-smartpart-in-sharepoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using ISAPI Rewrite to redirect domain.com to www.domain.com</title>
		<link>http://chris.gg/2010/03/using-isapi-rewrite-to-redirect-domain-com-to-www-domain-com/</link>
		<comments>http://chris.gg/2010/03/using-isapi-rewrite-to-redirect-domain-com-to-www-domain-com/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 12:18:00 +0000</pubDate>
		<dc:creator>Chris Barnes</dc:creator>
				<category><![CDATA[Hints & Tips]]></category>
		<category><![CDATA[isapi_rewrite]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[www]]></category>
		<guid isPermaLink="false">http://chris.gg/?p=643</guid>
		<description><![CDATA[My employer&#8217;s SharePoint-powered external website &#8211; which I look after &#8211; uses ISAPI Rewrite to provide &#8220;friendly&#8221; URLs for certain pages, and also to redirect old URLs to their new locations. Coming from a LAMP background, this is great for me as it basically works the same as Apache&#8217;s mod_rewrite. Previously the website responded to [...]]]></description>
			<content:encoded><![CDATA[<p>My employer&#8217;s SharePoint-powered external website &#8211; which I look after &#8211; uses <a href="http://www.isapirewrite.com/">ISAPI Rewrite</a> to provide &#8220;friendly&#8221; URLs for certain pages, and also to redirect old URLs to their new locations. Coming from a <acronym title="Linux, Apache, MySQL, PHP">LAMP</acronym> background, this is great for me as it basically works the same as Apache&#8217;s <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html">mod_rewrite</a>.</p>
<p>Previously the website responded to requests for both <strong>domain.com</strong> and <strong>www.domain.com</strong>, which is not ideal. <acronym title="Search Engine Optimisation">SEO</acronym> best practice is to either redirect the non-WWW version to the WWW version, or vice-versa. In my case, <strong>www.domain.com</strong> is the preferred format, so I&#8217;m using the following rule:</p>
<pre lang="mysql">### Redirect domain.com to www.domain.com
RewriteCond Host: ^domain\.com
RewriteRule (.*) http\://www\.domain\.com$1 [I,RP]</pre>
<p>If you want to do the opposite, you&#8217;ll need this one:</p>
<pre lang="mysql">### Redirect www.domain.com to domain.com
RewriteCond Host: ^www\.domain\.com
RewriteRule (.*) http\://domain\.com$1 [I,RP]</pre>
]]></content:encoded>
			<wfw:commentRss>http://chris.gg/2010/03/using-isapi-rewrite-to-redirect-domain-com-to-www-domain-com/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SharePoint and getElementById()</title>
		<link>http://chris.gg/2010/02/sharepoint-and-getelementbyid/</link>
		<comments>http://chris.gg/2010/02/sharepoint-and-getelementbyid/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 15:18:17 +0000</pubDate>
		<dc:creator>Chris Barnes</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[getelementbyid]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[sharepoint]]></category>
		<guid isPermaLink="false">http://chris.gg/?p=624</guid>
		<description><![CDATA[I&#8217;ve just found out that using JavaScript&#8217;s getElementById() function doesn&#8217;t quite work as expected when dealing with controls on SharePoint pages. This is because SharePoint uses its own identifiers, so TextBox1 becomes something like ctl00$ctl00$g_3f6d90e4_335b_467c_a53f_6ae00bca6b63$ctl00$TextBox1. Fortunately there&#8217;s a simple solution &#8211; instead of the following (which will cause an &#8220;Object required&#8221; JavaScript error): document.getElementById("TextBox1"); you need [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just found out that using JavaScript&#8217;s <strong>getElementById()</strong> function doesn&#8217;t quite work as expected when dealing with controls on SharePoint pages. This is because SharePoint uses its own identifiers, so <strong>TextBox1 </strong> becomes something like <strong>ctl00$ctl00$g_3f6d90e4_335b_467c_a53f_6ae00bca6b63$ctl00$TextBox1</strong>.</p>
<p>Fortunately there&#8217;s a simple solution &#8211; instead of the following (which will cause an &#8220;Object required&#8221; JavaScript error):</p>
<pre lang="csharp">document.getElementById("TextBox1");</pre>
<p>you need to use this, which will insert the correct full ID for the element and thus work correctly:</p>
<pre lang="csharp">document.getElementById("< %=TextBox1.ClientID%>");</pre>
<p>It gets a bit more complicated when using nested controls, which is explained in <a href="http://www.binarywave.com/blogs/eshupps/Lists/Posts/Post.aspx?List=9c93c708-e5ce-4714-bdea-499330361130&amp;ID=23">this post by Eric Shupps</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://chris.gg/2010/02/sharepoint-and-getelementbyid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to check whether a SharePoint user is in a particular group</title>
		<link>http://chris.gg/2010/02/how-to-check-whether-a-sharepoint-user-is-in-a-particular-group/</link>
		<comments>http://chris.gg/2010/02/how-to-check-whether-a-sharepoint-user-is-in-a-particular-group/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 17:00:51 +0000</pubDate>
		<dc:creator>Chris Barnes</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[group]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[smartpart]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[web part]]></category>
		<guid isPermaLink="false">http://chris.gg/?p=608</guid>
		<description><![CDATA[Here&#8217;s a quick function I wrote to check whether a user is a member of a particular SharePoint group: private bool IsMemberOf(string groupName) { SPUser user = SPContext.Current.Web.CurrentUser; try { if (user.Groups[groupName] != null) return true; else return false; } catch { return false; } } The try-catch is required as &#8211; somewhat counter-intuitively &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick function I wrote to check whether a user is a member of a particular SharePoint group:</p>
<pre lang="csharp">
private bool IsMemberOf(string groupName)
{
    SPUser user = SPContext.Current.Web.CurrentUser;
    try
    {
        if (user.Groups[groupName] != null)
            return true;
        else
            return false;
    }
    catch
    {
        return false;
    }
}
</pre>
<p>The try-catch is required as  &#8211; somewhat counter-intuitively &#8211; SharePoint seems to throw a &#8220;Group not found&#8221; error if the user is not a member of the group.</p>
]]></content:encoded>
			<wfw:commentRss>http://chris.gg/2010/02/how-to-check-whether-a-sharepoint-user-is-in-a-particular-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to set SharePoint page title programmatically</title>
		<link>http://chris.gg/2010/02/how-to-set-sharepoint-page-title-programmatically/</link>
		<comments>http://chris.gg/2010/02/how-to-set-sharepoint-page-title-programmatically/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 15:30:18 +0000</pubDate>
		<dc:creator>Chris Barnes</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[smartpart]]></category>
		<category><![CDATA[title]]></category>
		<category><![CDATA[web part]]></category>
		<guid isPermaLink="false">http://chris.gg/?p=600</guid>
		<description><![CDATA[I&#8217;ve spent some time today trying to figure out how to set the title of a SharePoint page from my own code. As blogger Michael Becker rightly points out, you can&#8217;t simply set Page.Title. The correct solution, as provided by Michael, is illustrated in this example C# code: // Get a reference to the appropriate [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve spent some time today trying to figure out how to set the title of a SharePoint page from my own code. As <a href="http://blogs.pointbridge.com/Blogs/becker_michael/Pages/Post.aspx?_ID=11">blogger Michael Becker rightly points out</a>, you can&#8217;t simply set <strong>Page.Title</strong>.</p>
<p>The correct solution, as provided by Michael, is illustrated in this example C# code:</p>
<pre lang="csharp">// Get a reference to the appropriate Content Placeholder
ContentPlaceHolder contentPlaceHolder = (ContentPlaceHolder)
                       Page.Master.FindControl("PlaceHolderPageTitle");
// Clear out anything that SharePoint might have put in it already
contentPlaceHolder.Controls.Clear();
// Put your content in
LiteralControl literalControl = new LiteralControl();
literalControl.Text = "Your text goes here";
contentPlaceHolder.Controls.Add(literalControl);</pre>
<p>Happily this even works when you &#8220;cheat&#8221; by hosting an ASP.NET user control within a <a href="http://www.codeplex.com/smartpart">SmartPart</a>, as opposed to creating a bona fide Web Part.</p>
]]></content:encoded>
			<wfw:commentRss>http://chris.gg/2010/02/how-to-set-sharepoint-page-title-programmatically/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Deploy ASP.NET web user controls on SharePoint using SmartPart</title>
		<link>http://chris.gg/2010/02/deploy-asp-net-web-user-controls-on-sharepoint-using-smartpart/</link>
		<comments>http://chris.gg/2010/02/deploy-asp-net-web-user-controls-on-sharepoint-using-smartpart/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 19:04:12 +0000</pubDate>
		<dc:creator>Chris Barnes</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[smartpart]]></category>
		<guid isPermaLink="false">http://chris.gg/?p=570</guid>
		<description><![CDATA[Today I&#8217;ve been playing with Return of SmartPart 1.3,  a shim which allows you to create SharePoint 2007 web parts using Web User Controls (ASCX files) created by Visual Studio/Visual Web Developer. This is probably the least painful way for C#/VB.NET developers to delve into web part building without having to worry too much about the intricacies [...]]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;ve been playing with <a href="http://smartpart.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=10697">Return of SmartPart 1.3</a>,  a shim which allows you to create SharePoint 2007 web parts using Web User Controls (ASCX files) created by Visual Studio/Visual Web Developer.</p>
<p>This is probably the least painful way for C#/VB.NET developers to delve into web part building without having to worry too much about the intricacies of the SharePoint platform.</p>
<p>Complete with setup wizard, comprehensive user guide and sample user controls, it&#8217;s a snap to get running, although you will need access to your SharePoint server both to install the SmartPart and any custom user controls. It also optionally supports AJAX controls, after installing Microsoft&#8217;s ASP.NET AJAX extensions.</p>
<p>There&#8217;s no need to use strong naming or even compile your controls &#8211; just drop the .ascx (and .ascx.cs/.vb, if necessary) files into your usercontrols directory and you&#8217;re good to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://chris.gg/2010/02/deploy-asp-net-web-user-controls-on-sharepoint-using-smartpart/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

