<?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>My Insights</title>
	<atom:link href="http://www.pranavsharma.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pranavsharma.com/blog</link>
	<description>A fresh perspective on the world of technology</description>
	<lastBuildDate>Fri, 16 Dec 2011 06:16:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Large list performance: SPMetal vs. SPQuery</title>
		<link>http://www.pranavsharma.com/blog/2011/12/16/large-list-performance-spmetal-vs-spquery/</link>
		<comments>http://www.pranavsharma.com/blog/2011/12/16/large-list-performance-spmetal-vs-spquery/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 06:14:20 +0000</pubDate>
		<dc:creator>Pranav Sharma</dc:creator>
				<category><![CDATA[Sharepoint 2010 (SPS / Foundation)]]></category>
		<category><![CDATA[CAML]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SPMetal]]></category>
		<category><![CDATA[SPQuery]]></category>
		<category><![CDATA[Throttle]]></category>

		<guid isPermaLink="false">http://www.pranavsharma.com/blog/2011/12/16/large-list-performance-spmetal-vs-spquery/</guid>
		<description><![CDATA[Key takeaway <p>Use SPQuery for large lists instead of SPMetal. While testing with a list of 45K items, SPQuery performed at 0.06s compared to SPMetal’s performance at 9.98s.</p> Background <p>I was recently faced with determining the storage mechanism for a custom application. The choices were ‘SharePoint lists vs. SQL tables’. The user interface of this [...]]]></description>
			<content:encoded><![CDATA[<h2>Key takeaway</h2>
<p>Use SPQuery for large lists instead of SPMetal. While testing with a list of 45K items, SPQuery performed at 0.06s compared to SPMetal’s performance at 9.98s.</p>
<h2>Background</h2>
<p>I was recently faced with determining the storage mechanism for a custom application. The choices were ‘<font color="#c0504d">SharePoint lists vs. SQL tables</font>’. The user interface of this application would be implemented as a set of webparts either way. Now SharePoint has the advantage on UI which allows end users to easily interact with the data. SQL on the other hand takes the trophy on performance. So the choice really boiled down to ‘<font color="#c0504d">End-User Access vs. Performance</font>’. I really liked the idea of users being able to interact with the data so the obvious question arose: Could SharePoint perform reasonably well when dealing with ‘large’ data sets?</p>
<h2>Throttle Levels</h2>
<p>What is considered ‘large’ in the SharePoint world? For end users, <font color="#c0504d">5000 items</font> is where SharePoint starts to throttle queries. Using the object model however, queries of over <font color="#c0504d">20,000 items</font> leads to an Expensive Query Exception. This behavior can be overriden by setting the SPQuery.QueryThrottleMode to SPQueryThrottleOption.Override. Additionally, these limits can be increased from Central Admin. So in order to create a large enough data set, let’s populated a blank custom list with 45,000 rows of data by setting the title column to a unique number. Additionally, for roughly 100 of these list items, let’s set a second column’s value (Column=Campaign) to a predetermined text since that way we can pull these 100 rows as part of a query.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">using</span> (var context = <span style="color: #0000ff">new</span> ClientDataContext(<span style="color: #006080">&quot;http://site&quot;</span>))</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = 0; i &lt; 45000; i++)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>         var newItem = <span style="color: #0000ff">new</span> PerfListItem {Title = i.ToString()};</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>             <span style="color: #0000ff">if</span> (i &gt;= 44900)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>                 newItem.Campaign = <span style="color: #006080">&quot;ABC&quot;</span>;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>             context.PerfList.InsertOnSubmit(newItem);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>     context.SubmitChanges();</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> }</pre>
<p><!--CRLF--></div>
</div>
<h2>Column Indexing</h2>
<p>Before diving into the test results, let me briefly point out that SharePoint list columns can be indexed for better performance. When dealing with large lists, throttling kicks in on <font color="#c0504d">sort</font>, <font color="#c0504d">where</font> and <font color="#c0504d">join</font> operations if dealing with non-indexed columns. For example, a where clause on a non-indexed column is a resource-intensive operation and SharePoint will throttle the query leading to unexpected results. The correct way to deal with large lists is to index any columns that would be used for any sorting, filtering or lookups. For the purposes of our test, I will be filtering based upon the ‘Campaign’ column so let’s add an index for that. Additionally, let’s add an index for the ‘Content Type’ column since SPMetal queries add a ContentTypeId filter to the underlying CAML.</p>
<h2>SPMetal Test</h2>
<p>Let me begin by saying that I’m a huge fan of SPMetal. For those who don’t know, SPMetal is a command-line tool that generates entity classes, which are primarily used in LINQ to SharePoint queries. Let’s setup this test as a simple filter query which consequently displays the count of the result set.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">using</span> (var context = <span style="color: #0000ff">new</span> ClientDataContext(<span style="color: #006080">&quot;http://site&quot;</span>))</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     var res = from item <span style="color: #0000ff">in</span> context.PerfList</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>               <span style="color: #0000ff">where</span> item.Campaign == <span style="color: #006080">&quot;ABC&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>               select item;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     Console.WriteLine(res.Count());</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>The result displayed a whopping count of 100 as expected and the execution time was an average of <font color="#c0504d">9.98s</font>. Test was conducted 3 times and the elapsed time was measured using System.Diagnostics.Stopwatch.</p>
<h2>Extracting SPMetal’s underlying CAML</h2>
<p>SPMetal’s performance of 9.98s wasn’t exactly stellar so let’s try a native CAML SPQuery instead. Since SPMetal ultimately turns LINQ queries into CAML queries, a fair test would be to try the SPMetal generated CAML query directly against the list. In order to extract the underlying query used by SPMetal, we can assign a TextWriter to the Log property of the data context.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> var sb = <span style="color: #0000ff">new</span> StringBuilder();</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> context.Log = <span style="color: #0000ff">new</span> StringWriter(sb);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #008000">//LINQ Query</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> Console.WriteLine(sb.ToString());</pre>
<p><!--CRLF--></div>
</div>
<p>This results in the following CAML-</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">View</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">Query</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">Where</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>       <span style="color: #0000ff">&lt;</span><span style="color: #800000">And</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">BeginsWith</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>           <span style="color: #0000ff">&lt;</span><span style="color: #800000">FieldRef</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">=&quot;ContentTypeId&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>           <span style="color: #0000ff">&lt;</span><span style="color: #800000">Value</span> <span style="color: #ff0000">Type</span><span style="color: #0000ff">=&quot;ContentTypeId&quot;</span><span style="color: #0000ff">&gt;</span>0x0100<span style="color: #0000ff">&lt;/</span><span style="color: #800000">Value</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>         <span style="color: #0000ff">&lt;/</span><span style="color: #800000">BeginsWith</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">Eq</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>           <span style="color: #0000ff">&lt;</span><span style="color: #800000">FieldRef</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">=&quot;Campaign&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>           <span style="color: #0000ff">&lt;</span><span style="color: #800000">Value</span> <span style="color: #ff0000">Type</span><span style="color: #0000ff">=&quot;Text&quot;</span><span style="color: #0000ff">&gt;</span>ABC<span style="color: #0000ff">&lt;/</span><span style="color: #800000">Value</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>         <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Eq</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>       <span style="color: #0000ff">&lt;/</span><span style="color: #800000">And</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Where</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span>   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Query</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">ViewFields</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">FieldRef</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">=&quot;Campaign&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum18">  18:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">FieldRef</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">=&quot;ID&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum19">  19:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">FieldRef</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">=&quot;owshiddenversion&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum20">  20:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">FieldRef</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">=&quot;FileDirRef&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum21">  21:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">FieldRef</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">=&quot;Title&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum22">  22:</span>   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">ViewFields</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum23">  23:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">RowLimit</span> <span style="color: #ff0000">Paged</span><span style="color: #0000ff">=&quot;TRUE&quot;</span><span style="color: #0000ff">&gt;</span>2147483647<span style="color: #0000ff">&lt;/</span><span style="color: #800000">RowLimit</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum24">  24:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">View</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<h2>SPQuery Test</h2>
<p>Finally, let’s setup the test for a native CAML SPQuery against the same list.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> var query = <span style="color: #0000ff">new</span> SPQuery</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>                 {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>                     ViewXml = <span style="color: #006080">&quot;&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;And&gt;&lt;BeginsWith&gt;&lt;FieldRef Name=\&quot;ContentTypeId\&quot; /&gt;&quot;</span> +</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>                     <span style="color: #006080">&quot;&lt;Value Type=\&quot;ContentTypeId\&quot;&gt;0x0100&lt;/Value&gt;&lt;/BeginsWith&gt;&lt;Eq&gt;&quot;</span> +</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>                     <span style="color: #006080">&quot;&lt;FieldRef Name=\&quot;Campaign\&quot; /&gt;&lt;Value Type=\&quot;Text\&quot;&gt;ABC&lt;/Value&gt;&lt;/Eq&gt;&quot;</span> +</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>                     <span style="color: #006080">&quot;&lt;/And&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;ViewFields&gt;&lt;FieldRef Name=\&quot;Campaign\&quot; /&gt;&quot;</span> +</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>                     <span style="color: #006080">&quot;&lt;FieldRef Name=\&quot;ID\&quot; /&gt;&lt;FieldRef Name=\&quot;owshiddenversion\&quot; /&gt;&quot;</span> +</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>                     <span style="color: #006080">&quot;&lt;FieldRef Name=\&quot;FileDirRef\&quot; /&gt;&lt;FieldRef Name=\&quot;Title\&quot; /&gt;&lt;/ViewFields&gt;&quot;</span> +</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>                     <span style="color: #006080">&quot;&lt;RowLimit Paged=\&quot;TRUE\&quot;&gt;2147483647&lt;/RowLimit&gt;&lt;/View&gt;&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>                 };</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">using</span> (var site = <span style="color: #0000ff">new</span> SPSite(<span style="color: #006080">&quot;http://site&quot;</span>))</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>     <span style="color: #0000ff">using</span> (SPWeb web = site.OpenWeb())</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>     {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span>         SPList list = web.Lists[<span style="color: #006080">&quot;PerfList&quot;</span>];</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span>         SPListItemCollection items =list.GetItems(query);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span>         Console.WriteLine(items.Count);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum18">  18:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum19">  19:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>The result? A surprising <font color="#c0504d">0.06s</font> on average! Again the test was conducted 3 times and elapsed the time was measured using System.Diagnostics.Stopwatch.</p>
<h2>Machine Specs</h2>
<p>For anyone that is interested, these tests were performed on a Windows 7 Client machine with Intel Core 2 Duo 2.66GHz &amp; 8GB RAM.</p>
<h2>Conclusion</h2>
<p>I finally got the answer to my initial question: It IS possible to both leverage the UI capabilities of SharePoint while working with large data sets. It is also painfully obvious that while SPMetal can save hours upon hours of development time, it clearly comes at a price. A price that gets prohibitively expensive as the data set grows in size. The lesson here is to be cognizant of the performance implications of SPMetal while balancing the need for faster development. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.pranavsharma.com/blog/2011/12/16/large-list-performance-spmetal-vs-spquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blank Open/Save Dialog when browsing Document Library from Office clients</title>
		<link>http://www.pranavsharma.com/blog/2011/08/28/blank-opensave-dialog-when-browsing-document-library-from-office-clients/</link>
		<comments>http://www.pranavsharma.com/blog/2011/08/28/blank-opensave-dialog-when-browsing-document-library-from-office-clients/#comments</comments>
		<pubDate>Sun, 28 Aug 2011 21:05:52 +0000</pubDate>
		<dc:creator>Pranav Sharma</dc:creator>
				<category><![CDATA[Sharepoint 2010 (SPS / Foundation)]]></category>
		<category><![CDATA[Blank]]></category>
		<category><![CDATA[Dialog]]></category>
		<category><![CDATA[Document Library]]></category>
		<category><![CDATA[Empty]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MS Word]]></category>
		<category><![CDATA[PowerPoint]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://www.pranavsharma.com/blog/2011/08/28/blank-opensave-dialog-when-browsing-document-library-from-office-clients/</guid>
		<description><![CDATA[Problem <p>When you browse to a document library from an office client dialog such as ‘MS Word &#62; Open’, the dialog shows a blank space instead of the document library contents-</p> <p><a href="http://www.pranavsharma.com/blog/wp-content/uploads/2011/08/image.png"></a></p> Root Cause <p>This issue is caused due to the lack of an appropriate ‘FormDialog’ view available in the document library schema. Any [...]]]></description>
			<content:encoded><![CDATA[<h2>Problem</h2>
<p>When you browse to a document library from an office client dialog such as ‘MS Word &gt; Open’, the dialog shows a blank space instead of the document library contents-</p>
<p><a href="http://www.pranavsharma.com/blog/wp-content/uploads/2011/08/image.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.pranavsharma.com/blog/wp-content/uploads/2011/08/image_thumb.png" width="644" height="484" /></a></p>
<h2>Root Cause</h2>
<p>This issue is caused due to the lack of an appropriate ‘FormDialog’ view available in the document library schema. Any document library definitions created by Visual Studio 2010 suffer from this issue. If you notice, these DocLib schemas provisioned by VS do actually contain a stub for a file dialog view but this stub is not sufficient in and of itself for proper rendering within an office client dialog-</p>
<blockquote><pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">View</span> <span class="attr">BaseViewID</span><span class="kwrd">=&quot;2&quot;</span> <span class="attr">Type</span><span class="kwrd">=&quot;HTML&quot;</span> <span class="attr">FileDialog</span><span class="kwrd">=&quot;TRUE&quot;</span> <span class="attr">TabularView</span><span class="kwrd">=&quot;FALSE&quot;</span> <span class="attr">DisplayName</span><span class="kwrd">=&quot;$Resources:core,File_Dialog_View;&quot;</span> <span class="attr">Hidden</span><span class="kwrd">=&quot;TRUE&quot;</span> <span class="attr">Path</span><span class="kwrd">=&quot;filedlg.htm&quot;</span> <span class="attr">ModerationType</span><span class="kwrd">=&quot;Moderator&quot;</span><span class="kwrd">&gt;</span></pre>
</blockquote>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<h2>Solution</h2>
<p>If you are in fact working with a visual studio provisioned schema for a document library (most common scenario for this issue) then simply find the FileDialog view (BaseViewId=”2” as shown above) and make the following modifications to the view-</p>
<ol>
<li>Remove the toolbar<br />
<blockquote>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">Toolbar</span> <span class="attr">Type</span><span class="kwrd">=&quot;Standard&quot;</span> <span class="kwrd">/&gt;</span></pre>
</blockquote>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</li>
<li>Add ViewHeader<br />
    </p>
<blockquote>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">ViewHeader</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">SetVar</span> <span class="attr">Name</span><span class="kwrd">=&quot;FileDialog&quot;</span><span class="kwrd">&gt;</span>1<span class="kwrd">&lt;/</span><span class="html">SetVar</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;!</span>[CDATA[
    <span class="kwrd">&lt;</span><span class="html">table</span> <span class="attr">id</span><span class="kwrd">=&quot;FileDialogViewTable&quot;</span> <span class="attr">width</span><span class="kwrd">=&quot;100%&quot;</span> <span class="attr">style</span><span class="kwrd">=&quot;cursor: default;&quot;</span> <span class="attr">border</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">rules</span><span class="kwrd">=&quot;rows&quot;</span> <span class="attr">cellspacing</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">cellpadding</span><span class="kwrd">=&quot;2&quot;</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">tr</span><span class="kwrd">&gt;</span>
]]<span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">Fields</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;&lt;!</span>[CDATA[<span class="kwrd">&lt;</span><span class="html">th</span> <span class="attr">class</span><span class="kwrd">=&quot;ms-vh2-nofilter&quot;</span><span class="kwrd">&gt;</span>]]<span class="kwrd">&gt;&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Field</span> <span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;&lt;!</span>[CDATA[<span class="kwrd">&lt;/</span><span class="html">th</span><span class="kwrd">&gt;</span>]]<span class="kwrd">&gt;&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">Fields</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;&lt;!</span>[CDATA[<span class="kwrd">&lt;/</span><span class="html">tr</span><span class="kwrd">&gt;</span>]]<span class="kwrd">&gt;&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">ViewHeader</span><span class="kwrd">&gt;</span></pre>
</blockquote>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</li>
<li>Add ViewBody<br />
    </p>
<blockquote>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">ViewBody</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">SetVar</span> <span class="attr">Name</span><span class="kwrd">=&quot;FileDialog&quot;</span><span class="kwrd">&gt;</span>1<span class="kwrd">&lt;/</span><span class="html">SetVar</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">IfEqual</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Expr1</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">GetVar</span> <span class="attr">Name</span><span class="kwrd">=&quot;AlternateStyle&quot;</span> <span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">Expr1</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Expr2</span><span class="kwrd">&gt;</span>ms-alternating<span class="kwrd">&lt;/</span><span class="html">Expr2</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Then</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">SetVar</span> <span class="attr">Scope</span><span class="kwrd">=&quot;Request&quot;</span> <span class="attr">Name</span><span class="kwrd">=&quot;AlternateStyle&quot;</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;/</span><span class="html">SetVar</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">Then</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Else</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">SetVar</span> <span class="attr">Scope</span><span class="kwrd">=&quot;Request&quot;</span> <span class="attr">Name</span><span class="kwrd">=&quot;AlternateStyle&quot;</span><span class="kwrd">&gt;</span>ms-alternating<span class="kwrd">&lt;/</span><span class="html">SetVar</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">Else</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">IfEqual</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">Switch</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Expr</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">LookupColumn</span> <span class="attr">Name</span><span class="kwrd">=&quot;FSObjType&quot;</span> <span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">Expr</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Case</span> <span class="attr">Value</span><span class="kwrd">=&quot;1&quot;</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;</span><span class="attr">&amp;lt;</span>TR fileattribute=folder ID=&quot;<span class="kwrd">&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">Case</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Default</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;</span><span class="attr">&amp;lt;</span>TR fileattribute=file ID=&quot;<span class="kwrd">&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">Default</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">Switch</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">Field</span> <span class="attr">Name</span><span class="kwrd">=&quot;EncodedAbsUrl&quot;</span> <span class="kwrd">/&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;&lt;!</span>[CDATA[&quot; class=&quot;]]<span class="kwrd">&gt;&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">GetVar</span> <span class="attr">Name</span><span class="kwrd">=&quot;AlternateStyle&quot;</span> <span class="kwrd">/&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;&lt;!</span>[CDATA[&quot; onmousedown=&quot;selectrow()&quot; onclick=&quot;selectrow()&quot;<span class="kwrd">&gt;</span>]]<span class="kwrd">&gt;&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">Fields</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;&lt;!</span>[CDATA[<span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">class</span><span class="kwrd">=&quot;ms-vb&quot;</span> <span class="attr">style</span><span class="kwrd">=&quot;padding-left: 4px&quot;</span><span class="kwrd">&gt;</span>]]<span class="kwrd">&gt;&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">FieldSwitch</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">Expr</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">Property</span> <span class="attr">Select</span><span class="kwrd">=&quot;Type&quot;</span> <span class="kwrd">/&gt;</span>
      <span class="kwrd">&lt;/</span><span class="html">Expr</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">Case</span> <span class="attr">Value</span><span class="kwrd">=&quot;User&quot;</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">LookupColumn</span> <span class="attr">HTMLEncode</span><span class="kwrd">=&quot;TRUE&quot;</span> <span class="kwrd">/&gt;</span>
      <span class="kwrd">&lt;/</span><span class="html">Case</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">Default</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">FieldSwitch</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">Expr</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Property</span> <span class="attr">Select</span><span class="kwrd">=&quot;Name&quot;</span> <span class="kwrd">/&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">Expr</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">Case</span> <span class="attr">Value</span><span class="kwrd">=&quot;CheckoutUser&quot;</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Field</span> <span class="attr">HTMLEncode</span><span class="kwrd">=&quot;TRUE&quot;</span> <span class="kwrd">/&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">Case</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">Default</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Field</span> <span class="kwrd">/&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">Default</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">FieldSwitch</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;/</span><span class="html">Default</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">FieldSwitch</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;&lt;!</span>[CDATA[<span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;</span>]]<span class="kwrd">&gt;&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">Fields</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;&lt;!</span>[CDATA[<span class="kwrd">&lt;/</span><span class="html">tr</span><span class="kwrd">&gt;</span>]]<span class="kwrd">&gt;&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">ViewBody</span><span class="kwrd">&gt;</span></pre>
</blockquote>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</li>
<li>Add ViewFooter<br />
    </p>
<blockquote>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">ViewFooter</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;&lt;!</span>[CDATA[<span class="kwrd">&lt;/</span><span class="html">table</span><span class="kwrd">&gt;</span>]]<span class="kwrd">&gt;&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">ViewFooter</span><span class="kwrd">&gt;</span></pre>
</blockquote>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</li>
<li>Add ViewEmpty<br />
    </p>
<blockquote>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">ViewEmpty</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">SetVar</span> <span class="attr">Name</span><span class="kwrd">=&quot;FileDialog&quot;</span><span class="kwrd">&gt;</span>1<span class="kwrd">&lt;/</span><span class="html">SetVar</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;!</span>[CDATA[
    <span class="kwrd">&lt;</span><span class="html">table</span> <span class="attr">id</span><span class="kwrd">=&quot;FileDialogViewTable&quot;</span> <span class="attr">width</span><span class="kwrd">=&quot;100%&quot;</span> <span class="attr">style</span><span class="kwrd">=&quot;cursor: default;&quot;</span> <span class="attr">border</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">rules</span><span class="kwrd">=&quot;rows&quot;</span> <span class="attr">cellspacing</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">cellpadding</span><span class="kwrd">=&quot;2&quot;</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">tr</span><span class="kwrd">&gt;</span>
]]<span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">Fields</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Switch</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">Expr</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">Property</span> <span class="attr">Select</span><span class="kwrd">=&quot;Name&quot;</span> <span class="kwrd">/&gt;</span>
      <span class="kwrd">&lt;/</span><span class="html">Expr</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">Case</span> <span class="attr">Value</span><span class="kwrd">=&quot;FileLeafRef&quot;</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;/</span><span class="html">Case</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">Default</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;&lt;!</span>[CDATA[<span class="kwrd">&lt;</span><span class="html">th</span> <span class="attr">class</span><span class="kwrd">=&quot;ms-vh2-nofilter&quot;</span><span class="kwrd">&gt;</span>]]<span class="kwrd">&gt;&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">Field</span> <span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;&lt;!</span>[CDATA[<span class="kwrd">&lt;/</span><span class="html">th</span><span class="kwrd">&gt;</span>]]<span class="kwrd">&gt;&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;/</span><span class="html">Default</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">Switch</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">Fields</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;&lt;!</span>[CDATA[<span class="kwrd">&lt;/</span><span class="html">tr</span><span class="kwrd">&gt;&lt;/</span><span class="html">table</span><span class="kwrd">&gt;</span>]]<span class="kwrd">&gt;&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;&lt;!</span>[CDATA[<span class="kwrd">&lt;</span><span class="html">table</span> <span class="attr">width</span><span class="kwrd">=&quot;100%&quot;</span> <span class="attr">border</span><span class="kwrd">=&quot;0&quot;</span> <span class="attr">rules</span><span class="kwrd">=&quot;rows&quot;</span><span class="kwrd">&gt;&lt;</span><span class="html">tr</span><span class="kwrd">&gt;</span>]]<span class="kwrd">&gt;&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;&lt;!</span>[CDATA[<span class="kwrd">&lt;</span><span class="html">td</span> <span class="attr">class</span><span class="kwrd">=&quot;ms-vb&quot;</span><span class="kwrd">&gt;</span>]]<span class="kwrd">&gt;&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;</span>$Resources:core,noDocOfSpecType;<span class="kwrd">&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">HTML</span><span class="kwrd">&gt;&lt;!</span>[CDATA[<span class="kwrd">&lt;/</span><span class="html">td</span><span class="kwrd">&gt;&lt;/</span><span class="html">tr</span><span class="kwrd">&gt;&lt;/</span><span class="html">table</span><span class="kwrd">&gt;</span>]]<span class="kwrd">&gt;&lt;/</span><span class="html">HTML</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">ViewEmpty</span><span class="kwrd">&gt;</span></pre>
</blockquote>
</li>
</ol>
<h2><span class="kwrd">Things to note</span></h2>
<ol>
<li>
<div><span class="kwrd">If you’re creating your own list schema by hand, simply ensure that there is a view definition with the following attributes-<br />
        <br /></span></p>
<blockquote>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">View</span> <span class="attr">BaseViewID</span><span class="kwrd">=&quot;&quot;</span> <span class="attr">Type</span><span class="kwrd">=&quot;HTML&quot;</span> <span class="attr">FileDialog</span><span class="kwrd">=&quot;TRUE&quot;</span> <span class="attr">TabularView</span><span class="kwrd">=&quot;FALSE&quot;</span> <span class="attr">DisplayName</span><span class="kwrd">=&quot;&quot;</span> <span class="attr">Hidden</span><span class="kwrd">=&quot;TRUE&quot;</span> <span class="attr">Path</span><span class="kwrd">=&quot;filedlg.htm&quot;</span> <span class="attr">ModerationType</span><span class="kwrd">=&quot;Moderator&quot;</span><span class="kwrd">&gt;</span></pre>
</blockquote>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</div>
</li>
<li>
<p><span class="kwrd">For lists that have already been provisioned using a custom schema, simply update the schema definition and redeploy to enact the change in existing list instances. Be sure to re-activate the feature so that an updated schema is read from the disk.</span></p>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.pranavsharma.com/blog/2011/08/28/blank-opensave-dialog-when-browsing-document-library-from-office-clients/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rendering User Control ASCX via XSL in SharePoint</title>
		<link>http://www.pranavsharma.com/blog/2011/08/12/rendering-user-control-ascx-via-xsl-in-sharepoint/</link>
		<comments>http://www.pranavsharma.com/blog/2011/08/12/rendering-user-control-ascx-via-xsl-in-sharepoint/#comments</comments>
		<pubDate>Fri, 12 Aug 2011 17:19:50 +0000</pubDate>
		<dc:creator>Pranav Sharma</dc:creator>
				<category><![CDATA[Sharepoint 2007 ( MOSS / WSS )]]></category>
		<category><![CDATA[Sharepoint 2010 (SPS / Foundation)]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[ASCX]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[User Control]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XSL]]></category>
		<category><![CDATA[XSLT]]></category>

		<guid isPermaLink="false">http://www.pranavsharma.com/blog/2011/08/12/rendering-user-control-ascx-via-xsl-in-sharepoint/</guid>
		<description><![CDATA[Background &#38; The Problem <p>Last time we discussed <a href="http://www.pranavsharma.com/blog/2011/06/08/custom-user-controls-in-xslt/">how to integrate a custom control into an XSL transformation</a>. The key point to note about the previously discussed approach is that all the markup is output by the overridden Render method. This can easily get cumbersome and ineffective for complex server side controls. The ASP.net [...]]]></description>
			<content:encoded><![CDATA[<h2>Background &amp; The Problem</h2>
<p>Last time we discussed <a href="http://www.pranavsharma.com/blog/2011/06/08/custom-user-controls-in-xslt/">how to integrate a custom control into an XSL transformation</a>. The key point to note about the previously discussed approach is that all the markup is output by the overridden Render method. This can easily get cumbersome and ineffective for complex server side controls. The ASP.net stack offers us a solution to this common problem with Control definitions. This solution is a UserControl which adds a special ASCX file containing declarative markup which makes the development task much easier, simpler &amp; cleaner. </p>
<p>In this post, we will show how to incorporate a server side UserControl with markup in it’s ASCX file to render within an XSLT instead of a simple Control definition.</p>
<h2>How to do this</h2>
<p>In order to render a UserControl ASCX within an XSLT, we need to follow a slightly different method that the one discussed in the previous post. Here are the steps-</p>
<ol>
<li>First thing we need to do is to define our user control. Here is a sample ASCX definition. Notice that this control renders a variable called ‘Input’ which we will also define in the code-behind class in the next step-      <br /> <br />
<blockquote>
<pre class="csharpcode"><span class="asp">&lt;%@ Assembly Name=&quot;$SharePoint.Project.AssemblyFullName$&quot; %&gt;</span>
<span class="asp">&lt;%@ Assembly Name=&quot;Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %&gt;</span>
<span class="asp">&lt;%@ Control Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;DemoControl.ascx.cs&quot; Inherits=&quot;Demo.ControlTemplates.DemoControl&quot; %&gt;</span>

<span class="kwrd">&lt;</span><span class="html">div</span><span class="kwrd">&gt;</span>(<span class="asp">&lt;%</span>= Input <span class="asp">%&gt;</span>)<span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span></pre>
</blockquote>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</li>
<li>Next, we define the code-behind that our ASCX inherits from. Notice that we are declaring a public string property called ‘Input’ whose value is being directly rendered within the ASCX as an example. This variable is used to accept contextual information about the XML node being processed by the XSL transform at the time of evaluating this control during the runtime-<br />
    </p>
<blockquote>
<pre class="csharpcode"><span class="kwrd">using</span> System.Web.UI;

<span class="kwrd">namespace</span> Demo.ControlTemplates
{
    <span class="kwrd">public</span> <span class="kwrd">partial</span> <span class="kwrd">class</span> DemoControl : UserControl
    {
        <span class="kwrd">public</span> <span class="kwrd">string</span> Input;
    }
}</pre>
</blockquote>
<ol><!--EndFragment--></ol>
</li>
<li>Next, we need to globally register our user control so that our XSLT can find it. This is done because we don’t have the ability to register custom user controls from within an XSLT webpart. The following registration happens in the web.config in this node: &lt;configuration&gt;…&lt;system.web&gt;…&lt;pages&gt;…&lt;controls&gt;. Notice that we assign a tagName for this user control. This tag name will be used when we reference the user control in our XSLT-<br />
    </p>
<blockquote>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">tagPrefix</span><span class="kwrd">=&quot;PSControl&quot;</span> <span class="attr">src</span><span class="kwrd">=&quot;/_controltemplates/demo/democontrol.ascx&quot;</span> <span class="attr">tagName</span><span class="kwrd">=&quot;PSC&quot;</span><span class="kwrd">/&gt;</span></pre>
</blockquote>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</li>
<li>Now that SharePoint globally knows about this user control, we need to modify our xsl declaration to assign a tag prefix for this control so that we can reference it wherever we want to use it. In this case, our tag prefix is ‘PSControl’-<br />
    </p>
<blockquote>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">xsl:stylesheet</span> <span class="attr">version</span><span class="kwrd">=&quot;1.0&quot;</span> <span class="attr">xmlns:xsl</span><span class="kwrd">=&quot;http://www.w3.org/1999/XSL/Transform&quot;</span> <span class="attr">xmlns:PSControl</span><span class="kwrd">=&quot;Demo.ControlTemplates&quot;</span> <span class="kwrd">&gt;</span></pre>
</blockquote>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</li>
<li>Now that everything has been setup, we can simply reference our custom user control using the tag prefix defined in step 4 (PSControl) and the tag name defined in step 3 (PSC). Combined this tag declaration allows us to render our custom user control ASCX which was written declaratively to save development time associated with defining a custom server side control for our XSLT. Notice that we are using the Input property defined in the UserControl and passing it contextual value about the current node&#160; being processed in this case-<br />
    </p>
<blockquote>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">PSControl:PSC</span> <span class="attr">Input</span><span class="kwrd">=&quot;{title}&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="kwrd">/&gt;</span></pre>
</blockquote>
</li>
</ol>
<p>That’s it! You can now write declarative markup in a UserControl ASCX file and have that markup process XML nodes using a code-behind, all within the context of an XSL transform.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pranavsharma.com/blog/2011/08/12/rendering-user-control-ascx-via-xsl-in-sharepoint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Controls in XSLT</title>
		<link>http://www.pranavsharma.com/blog/2011/06/08/custom-user-controls-in-xslt/</link>
		<comments>http://www.pranavsharma.com/blog/2011/06/08/custom-user-controls-in-xslt/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 19:04:31 +0000</pubDate>
		<dc:creator>Pranav Sharma</dc:creator>
				<category><![CDATA[Sharepoint 2007 ( MOSS / WSS )]]></category>
		<category><![CDATA[Sharepoint 2010 (SPS / Foundation)]]></category>
		<category><![CDATA[Control]]></category>
		<category><![CDATA[ddwrt]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XSL]]></category>
		<category><![CDATA[XSLT]]></category>

		<guid isPermaLink="false">http://www.pranavsharma.com/blog/2011/06/08/custom-user-controls-in-xslt/</guid>
		<description><![CDATA[Background &#38; The Dream <p>SharePoint relies heavily on XML data and XSLT processing of such data. Whether we are dealing with Search results, Data view web parts or Content Query web parts, XSLT processing is something all SharePoint developers have to deal with on regular basis. SharePoint provides an XSLT extension object called ddwrt to [...]]]></description>
			<content:encoded><![CDATA[<h2>Background &amp; The Dream</h2>
<p>SharePoint relies heavily on XML data and XSLT processing of such data. Whether we are dealing with Search results, Data view web parts or Content Query web parts, XSLT processing is something all SharePoint developers have to deal with on regular basis. SharePoint provides an XSLT extension object called ddwrt to perform tasks such as accessing properties of a SharePoint list or firing events to connected Web Parts.</p>
<p>Even though XSL transforms are incredibly powerful, especially with the availability of extension objects like ddwrt, sometimes it is much quicker and easier to perform advanced processing using server side controls. In other cases, it’s almost a necessity. Imagine being able to take xml data and query external web services during the transformation process to render customized contextual information about the data being displayed to the user. </p>
<p>For example, let’s say we were to implement a staff directory using SharePoint people search. The underlying data is stored in the User Profile service application and the results are rendered using the people core results web part. However what if instead of simply displaying a list of people, we additionally wanted to display a list of projects that they are participating in? In this case, imagine the power of being able to insert a server side control in the XSLT to query a 3rd party project management system to retrieve the list of a particular user’s projects and then rendering that nested within the rest of the XSL transform</p>
<h2>How to do it</h2>
<p>There are 4 steps needed in order to be able to insert server side controls within a SharePoint XSLT-</p>
<ol>
<li>First thing we need to do is to write the control that we will be inserting into our XSLT. Notice that we are declaring two public properties called ‘itemUrl’ and ‘print’. These properties are used to pass xml data at run-time into our control. We are also overriding the Render method which is used to spit out the code that will be output to the end user-</li>
<blockquote><pre class="csharpcode"><span class="kwrd">namespace</span> PortalSolutions.WebUI.Controls
{
    <span class="kwrd">public</span> <span class="kwrd">class</span> SampleFields : Control
    {
        <span class="kwrd">public</span> <span class="kwrd">string</span> itemUrl;
        <span class="kwrd">public</span> <span class="kwrd">string</span> print;

        <span class="kwrd">protected</span> <span class="kwrd">override</span> <span class="kwrd">void</span> Render(HtmlTextWriter writer)
        {
            writer.Write(<span class="str">&quot;&lt;div&gt;Hello World&lt;/div&gt;&quot;</span>);
        }
    }
}</pre>
</blockquote>
<li>The next thing for us to accomplish is to globally register our assembly and a tagPrefix for this assembly so that SharePoint can find our control. This is done because we don’t have access to register our assembly from within the XSL editor on SharePoint web parts. This registration is added in the web.config under the following node:&#160; &lt;configuration&gt;…&lt;system.web&gt;…&lt;pages&gt;…&lt;controls&gt;-<br />
    </p>
<blockquote>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">tagPrefix</span><span class="kwrd">=&quot;PS&quot;</span> <span class="attr">namespace</span><span class="kwrd">=&quot;PortalSolutions.WebUI.Controls&quot;</span> <span class="attr">assembly</span><span class="kwrd">=&quot;PortalSolutions.WebUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=00aaa666444222cc&quot;</span> <span class="kwrd">/&gt;</span></pre>
</blockquote>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</li>
<li>Now that SharePoint knows about our assembly and can find the control, we have add a declaration on top of XSL to attach a prefix to our namespace so that we can reference our control. In this case, ‘PS’ is the tag prefix we will be using-<br />
    </p>
<blockquote>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">xsl:stylesheet</span> <span class="attr">version</span><span class="kwrd">=&quot;1.0&quot;</span> <span class="attr">xmlns:xsl</span><span class="kwrd">=&quot;http://www.w3.org/1999/XSL/Transform&quot;</span> <span class="attr">xmlns:PS</span><span class="kwrd">=&quot;PortalSolutions.WebUI.Controls&quot;</span> <span class="kwrd">&gt;</span></pre>
</blockquote>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</li>
<li>Finally, now that we have everything set, we simply have to reference our control where we want to render it by using our tag prefix we registered in step 3 and the name of our control class which in this case is ‘SampleFields’. Additionally we use the public properties declared in the control definition as attributes in our XSL to pass in any information that the control may need to process the current XML node-<br />
    </p>
<blockquote>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">PS:SampleFields</span> <span class="attr">itemUrl</span><span class="kwrd">=&quot;{$url}&quot;</span> <span class="attr">print</span><span class="kwrd">=&quot;HelloWorld&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="kwrd">/&gt;</span></pre>
</blockquote>
</li>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</ol>
<p>And there we have it! A custom server side control puts a lot of power in the hands of developers looking to deliver some really powerful and amazing solutions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pranavsharma.com/blog/2011/06/08/custom-user-controls-in-xslt/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Missing User Profile values after migration</title>
		<link>http://www.pranavsharma.com/blog/2011/04/14/missing-user-profile-values-after-migration/</link>
		<comments>http://www.pranavsharma.com/blog/2011/04/14/missing-user-profile-values-after-migration/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 15:08:41 +0000</pubDate>
		<dc:creator>Pranav Sharma</dc:creator>
				<category><![CDATA[Sharepoint 2007 ( MOSS / WSS )]]></category>
		<category><![CDATA[Sharepoint 2010 (SPS / Foundation)]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[User Profile]]></category>

		<guid isPermaLink="false">http://www.pranavsharma.com/blog/2011/04/14/missing-user-profile-values-after-migration/</guid>
		<description><![CDATA[Problem <p>Are you missing user profile values for certain fields after a migration of the SSP database to SharePoint 2010 User Profile Service Application? If you look closely, the properties that are missing are managed metadata properties and this is a common oversight during a migration. </p> Solution <p>Run the “Move-SPProfileManagedMetadataProperty” commandlet on each of [...]]]></description>
			<content:encoded><![CDATA[<h2>Problem</h2>
<p>Are you missing user profile values for certain fields after a migration of the SSP database to SharePoint 2010 User Profile Service Application? If you look closely, the properties that are missing are managed metadata properties and this is a common oversight during a migration. </p>
<h2>Solution</h2>
<p>Run the “Move-SPProfileManagedMetadataProperty” commandlet on each of the missing properties-</p>
<blockquote><p>Move-SPProfileManagedMetadataProperty      <br />-ProfileServiceApplicationProxy ee475d63-fa17-4439-ac5c-656c164a86c3 -Identity SPS-Skills -AvailableForTagging       <br />-TermSetName myTermSet</p>
</blockquote>
<ol>
<li>SPS-School </li>
<li>LanguagesSpoken </li>
<li>Areasofexpertise </li>
<li>Areasofstudy </li>
<li>Degrees </li>
<li>SPS-Responsibility </li>
<li>SPS-Skills </li>
<li>SPS-PastProjects </li>
<li>AreasofInterest </li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.pranavsharma.com/blog/2011/04/14/missing-user-profile-values-after-migration/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Search Results Hidden Object</title>
		<link>http://www.pranavsharma.com/blog/2011/04/13/search-results-hidden-object/</link>
		<comments>http://www.pranavsharma.com/blog/2011/04/13/search-results-hidden-object/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 01:54:50 +0000</pubDate>
		<dc:creator>Pranav Sharma</dc:creator>
				<category><![CDATA[Sharepoint 2007 ( MOSS / WSS )]]></category>
		<category><![CDATA[Sharepoint 2010 (SPS / Foundation)]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[WSS]]></category>

		<guid isPermaLink="false">http://www.pranavsharma.com/blog/2011/04/13/search-results-hidden-object/</guid>
		<description><![CDATA[<p>SharePoint search webparts leverage an internal private class called SearchResultsHiddenObject which does a lot of heavy lifting around query execution. This object is also responsible for ‘connecting’ results between webparts such as the Paging, Core Results and Search Actions webparts. Now what if you want to do a custom keyword query or perhaps even a [...]]]></description>
			<content:encoded><![CDATA[<p>SharePoint search webparts leverage an internal private class called SearchResultsHiddenObject which does a lot of heavy lifting around query execution. This object is also responsible for ‘connecting’ results between webparts such as the Paging, Core Results and Search Actions webparts. Now what if you want to do a custom keyword query or perhaps even a full text query? </p>
<p>The typical answer is to write a custom core results webpart, but what about the other related webparts? You could in theory write a new paging webpart and a new search actions webpart and so on but wouldn’t it be nice if all these related webparts just worked with your new core results webpart? The answer is that they can but you have to get a little creative about modifying the SearchResultsHiddenObject. Here is an example where we disable duplicate trimming for correct paging behavior-</p>
<pre class="csharpcode"><span class="kwrd">object</span> srho = HttpContext.Current.Items[<span class="str">&quot;OSSSRHDC_0&quot;</span>];
<span class="kwrd">if</span> (srho != <span class="kwrd">null</span>)
{
    Type srhoType = srho.GetType();
    FieldInfo startAt = srhoType.GetField(<span class="str">&quot;_DuplicatesRemoved&quot;</span>, BindingFlags.Instance | BindingFlags.NonPublic);
    startAt.SetValue(srho, <span class="kwrd">false</span>);
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Here is a great walkthrough by Corey Roth on this topic: <a title="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/06/09/new-web-part-for-wildcard-search-in-enterprise-search.aspx" href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/06/09/new-web-part-for-wildcard-search-in-enterprise-search.aspx">http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/06/09/new-web-part-for-wildcard-search-in-enterprise-search.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pranavsharma.com/blog/2011/04/13/search-results-hidden-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change display name on CBA dropdown items</title>
		<link>http://www.pranavsharma.com/blog/2011/03/01/change-display-name-on-cba-dropdown-items/</link>
		<comments>http://www.pranavsharma.com/blog/2011/03/01/change-display-name-on-cba-dropdown-items/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 07:00:35 +0000</pubDate>
		<dc:creator>Pranav Sharma</dc:creator>
				<category><![CDATA[Sharepoint 2010 (SPS / Foundation)]]></category>
		<category><![CDATA[CBA]]></category>
		<category><![CDATA[Claims]]></category>
		<category><![CDATA[Codeplex]]></category>
		<category><![CDATA[SharePoint 2010]]></category>

		<guid isPermaLink="false">http://www.pranavsharma.com/blog/2011/03/01/change-display-name-on-cba-dropdown-items/</guid>
		<description><![CDATA[<p>Here is an easy way to change the display names for the authentication providers on the claims drop down in sharepoint 2010. Simply create a new signin page with a LogonSelector control and add this to the code-behind:</p> <p><a href="http://www.pranavsharma.com/blog/wp-content/uploads/2011/03/oob_login.png"></a></p> protected override void OnPreRenderComplete(EventArgs e) { base.OnPreRenderComplete(e); var ntlm = ClaimsLogonSelector.Items.FindByText(&#34;Windows Authentication&#34;); if (ntlm != [...]]]></description>
			<content:encoded><![CDATA[<p>Here is an easy way to change the display names for the authentication providers on the claims drop down in sharepoint 2010. Simply create a new signin page with a LogonSelector control and add this to the code-behind:</p>
<p><a href="http://www.pranavsharma.com/blog/wp-content/uploads/2011/03/oob_login.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="oob_login" border="0" alt="oob_login" src="http://www.pranavsharma.com/blog/wp-content/uploads/2011/03/oob_login_thumb.png" width="598" height="300" /></a></p>
<pre class="csharpcode"><span class="kwrd">protected</span> <span class="kwrd">override</span> <span class="kwrd">void</span> OnPreRenderComplete(EventArgs e)
{
    <span class="kwrd">base</span>.OnPreRenderComplete(e);

    var ntlm = ClaimsLogonSelector.Items.FindByText(<span class="str">&quot;Windows Authentication&quot;</span>);
    <span class="kwrd">if</span> (ntlm != <span class="kwrd">null</span>)
    {
        ClaimsLogonSelector.Items.Remove(ntlm);
        ntlm.Text = <span class="str">&quot;Internal&quot;</span>;
        ClaimsLogonSelector.Items.Add(ntlm);
    }

    var fba = ClaimsLogonSelector.Items.FindByText(<span class="str">&quot;Forms Authentication&quot;</span>);
    <span class="kwrd">if</span> (fba != <span class="kwrd">null</span>)
    {
        ClaimsLogonSelector.Items.Remove(fba);
        fba.Text = <span class="str">&quot;Guest&quot;</span>;
        ClaimsLogonSelector.Items.Add(fba);
    }
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Implement this in addition to the automatic signin solution to automatically forward internal users to windows authentication for a seamless intranet experience: <a href="http://spautomaticsignin.codeplex.com/">http://spautomaticsignin.codeplex.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pranavsharma.com/blog/2011/03/01/change-display-name-on-cba-dropdown-items/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SharePoint 2010 Notifications &amp; Statuses</title>
		<link>http://www.pranavsharma.com/blog/2010/09/13/sharepoint-2010-notifications-statuses/</link>
		<comments>http://www.pranavsharma.com/blog/2010/09/13/sharepoint-2010-notifications-statuses/#comments</comments>
		<pubDate>Mon, 13 Sep 2010 22:11:22 +0000</pubDate>
		<dc:creator>Pranav Sharma</dc:creator>
				<category><![CDATA[Sharepoint 2010 (SPS / Foundation)]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[SP2010]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://www.pranavsharma.com/blog/2010/09/13/sharepoint-2010-notifications-statuses/</guid>
		<description><![CDATA[<p>While the new <a href="http://www.pranavsharma.com/blog/2010/08/31/how-to-leverage-sharepoint-2010-dialogs/">SharePoint 2010 Dialog</a> framework is great for modal interaction with the end user, there are times when a quick non-modal notification or a semi-permanent status message is more appropriate. The great news is that SP 2010 already ships with an OOTB Notification and Status framework in addition to the dialogs.</p> <p>Notification<br [...]]]></description>
			<content:encoded><![CDATA[<p>While the new <a href="http://www.pranavsharma.com/blog/2010/08/31/how-to-leverage-sharepoint-2010-dialogs/">SharePoint 2010 Dialog</a> framework is great for modal interaction with the end user, there are times when a quick non-modal notification or a semi-permanent status message is more appropriate. The great news is that SP 2010 already ships with an OOTB Notification and Status framework in addition to the dialogs.</p>
<p><strong><u>Notification<br /><a href="http://www.pranavsharma.com/blog/wp-content/uploads/2010/09/image2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.pranavsharma.com/blog/wp-content/uploads/2010/09/image_thumb2.png" width="617" height="137"/></a> </u></strong></p>
<p>Notifications show up on the top-right of a page and by default show for 5 seconds.</p>
<blockquote><pre class="csharpcode">SP.UI.Notify.addNotification(<span class="str">"Custom Notification (5 sec)"</span>, <span class="kwrd">false</span>);</pre>
</blockquote>
<p><strong><u>Status<br /><a href="http://www.pranavsharma.com/blog/wp-content/uploads/2010/09/image1.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.pranavsharma.com/blog/wp-content/uploads/2010/09/image_thumb1.png" width="618" height="122"/></a> </u></strong></p>
<p>Status messages are semi-permanent and stay on the screen until cleared</p>
<blockquote><pre class="csharpcode"><span class="kwrd">var</span> statusId = SP.UI.Status.addStatus(<span class="str">"Your email address has not yet been confirmed. &lt;a href='http://site'&gt;Click Here&lt;/a&gt; to resend a confirmation email"</span>);
SP.UI.Status.setStatusPriColor(statusId, <span class="str">'red'</span>);</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
</blockquote>
<pre class="csharpcode">&nbsp;</pre>
<pre class="csharpcode">Check out this MSDN article for more information: <a title="http://msdn.microsoft.com/en-us/library/ee658473.aspx" href="http://msdn.microsoft.com/en-us/library/ee658473.aspx">http://msdn.microsoft.com/en-us/library/ee658473.aspx</a></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.pranavsharma.com/blog/2010/09/13/sharepoint-2010-notifications-statuses/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to leverage SharePoint 2010 dialogs?</title>
		<link>http://www.pranavsharma.com/blog/2010/08/31/how-to-leverage-sharepoint-2010-dialogs/</link>
		<comments>http://www.pranavsharma.com/blog/2010/08/31/how-to-leverage-sharepoint-2010-dialogs/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 02:39:53 +0000</pubDate>
		<dc:creator>Pranav Sharma</dc:creator>
				<category><![CDATA[Sharepoint 2010 (SPS / Foundation)]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[SP2010]]></category>

		<guid isPermaLink="false">http://www.pranavsharma.com/blog/2010/08/31/how-to-leverage-sharepoint-2010-dialogs/</guid>
		<description><![CDATA[<p>SharePoint 2010 has a robust modal dialog system that can be easily leveraged to build highly interactive solutions. Imaging being able to&#160; pop-up item edit forms or displaying notifications all without redirecting the user back and forth!</p> <p>Here is the client side JavaScript that will allow you to open any page within a dialog box-</p> [...]]]></description>
			<content:encoded><![CDATA[<p>SharePoint 2010 has a robust modal dialog system that can be easily leveraged to build highly interactive solutions. Imaging being able to&#160; pop-up item edit forms or displaying notifications all without redirecting the user back and forth!</p>
<p>Here is the client side JavaScript that will allow you to open any page within a dialog box-</p>
<blockquote><pre class="csharpcode"><span class="rem">//Handle the DialogCallback callback</span>
<span class="kwrd">function</span> DialogCallback(dialogResult, returnValue){
    window.location = window.location;
}

<span class="rem">//Open the Dialog</span>
<span class="kwrd">function</span> OpenEditDialog(link){
    <span class="kwrd">var</span> options = {
        url:link + <span class="str">'&amp;IsDlg=1'</span>,
        width: 700,
        height: 700,
        dialogReturnValueCallback: DialogCallback};
    SP.UI.ModalDialog.showModalDialog(options);
}</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</blockquote>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>To invoke the dialog, simply call the OpenEditDialog function with the target URL.</p>
<p>Notice that the IsDlg=1 query string parameter is appended within the OpenEditDialog function. The presence of “IsDlg” dynamically loads the &quot;/_layouts/styles/dlgframe.css” file which applies “display:none” to all items using the “s4-notdlg” css class. This effectively hides items of this class in a dialog box. For example, v4.master uses the “s4-notdlg” class for the Ribbon control to hide the ribbon within dialogs.</p>
<p><strong>UPDATE (09/13/2010):</strong> There are times when a quick non-modal notification or a semi-permanent status message is more appropriate. Check out this post on how to leverage these new UI frameworks: <a title="http://www.pranavsharma.com/blog/2010/09/13/sharepoint-2010-notifications-statuses/" href="http://www.pranavsharma.com/blog/2010/09/13/sharepoint-2010-notifications-statuses/">http://www.pranavsharma.com/blog/2010/09/13/sharepoint-2010-notifications-statuses/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pranavsharma.com/blog/2010/08/31/how-to-leverage-sharepoint-2010-dialogs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Inherit Site Theme programmatically</title>
		<link>http://www.pranavsharma.com/blog/2010/07/20/inherit-site-theme-programmatically/</link>
		<comments>http://www.pranavsharma.com/blog/2010/07/20/inherit-site-theme-programmatically/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 01:36:29 +0000</pubDate>
		<dc:creator>Pranav Sharma</dc:creator>
				<category><![CDATA[Sharepoint 2010 (SPS / Foundation)]]></category>
		<category><![CDATA[Object Model]]></category>
		<category><![CDATA[Programatically]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Site Theme]]></category>
		<category><![CDATA[SP2010]]></category>

		<guid isPermaLink="false">http://www.pranavsharma.com/blog/2010/07/20/inherit-site-theme-programmatically/</guid>
		<description><![CDATA[<p>The Microsoft.SharePoint.Utilities namespace contains a class called ThmxTheme which gives us some nice utility methods to interact with site themes in SharePoint 2010. Here is an example of how to automatically set the theme for a newly created SPWeb to be the same as the root web-</p> ThmxTheme.SetThemeUrlForWeb(newWeb, ThmxTheme.GetThemeUrlForWeb(newWeb.Site.RootWeb)); <p>Do you know of a nicer [...]]]></description>
			<content:encoded><![CDATA[<p>The Microsoft.SharePoint.Utilities namespace contains a class called ThmxTheme which gives us some nice utility methods to interact with site themes in SharePoint 2010. Here is an example of how to automatically set the theme for a newly created SPWeb to be the same as the root web-</p>
<blockquote><pre class="code"><span style="color: #2b91af">ThmxTheme</span>.SetThemeUrlForWeb(newWeb, <span style="color: #2b91af">ThmxTheme</span>.GetThemeUrlForWeb(newWeb.Site.RootWeb));</pre>
</blockquote>
<p>Do you know of a nicer way to inherit site themes? Please post a comment below.</p>
<p><strong>UPDATE (09/09/10)</strong>: An alternative way to do this-</p>
<blockquote>
<pre class="code"><span style="color: #2b91af">ThmxTheme </span>theme = <span style="color: #2b91af">ThmxTheme</span>.Open(web.Site, <span style="color: #a31515">&quot;_catalogs/theme/MyTheme.thmx&quot;</span>);
theme.ApplyTo(web, <span style="color: blue">true</span>);</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.pranavsharma.com/blog/2010/07/20/inherit-site-theme-programmatically/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

