<?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>jason&#039;s blog</title>
	<atom:link href="http://vspug.com/jason/feed/" rel="self" type="application/rss+xml" />
	<link>http://vspug.com/jason</link>
	<description>Just another VSPUG - Virtual SharePoint User Group weblog</description>
	<lastBuildDate>Mon, 17 Dec 2007 15:02:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Configuring IntelliSense with CAML Files When Developing for WSS 3.0</title>
		<link>http://vspug.com/jason/2007/12/17/configuring-intellisense-with-caml-files-when-developing-for-wss-3-0/</link>
		<comments>http://vspug.com/jason/2007/12/17/configuring-intellisense-with-caml-files-when-developing-for-wss-3-0/#comments</comments>
		<pubDate>Mon, 17 Dec 2007 15:02:00 +0000</pubDate>
		<dc:creator>jasonwj</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[From WSS visual How Tos,&#160; adding an Xml file for namespace http://schemas.microsoft.com/sharepoint in %ProgramFiels%Microsoft Visual Studio 8XmlSchema directory will bring the intellisense for feature, element manifest, and all other CAML oriented files developed in Visual Studio. 
]]></description>
			<content:encoded><![CDATA[<p>From <a href="http://msdn2.microsoft.com/en-us/library/bb507730.aspx" target="_blank">WSS visual How Tos</a>,&nbsp; adding an Xml file for namespace http://schemas.microsoft.com/sharepoint in %ProgramFiels%Microsoft Visual Studio 8XmlSchema directory will bring the intellisense for feature, element manifest, and all other CAML oriented files developed in Visual Studio. </p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jason/2007/12/17/configuring-intellisense-with-caml-files-when-developing-for-wss-3-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring IntelliSense with CAML Files When Developing for WSS 3.0</title>
		<link>http://vspug.com/jason/2007/12/17/configuring-intellisense-with-caml-files-when-developing-for-wss-3-0/</link>
		<comments>http://vspug.com/jason/2007/12/17/configuring-intellisense-with-caml-files-when-developing-for-wss-3-0/#comments</comments>
		<pubDate>Mon, 17 Dec 2007 15:02:00 +0000</pubDate>
		<dc:creator>jasonwj</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[From WSS visual How Tos,&#160; adding an Xml file for namespace http://schemas.microsoft.com/sharepoint in %ProgramFiels%Microsoft Visual Studio 8XmlSchema directory will bring the intellisense for feature, element manifest, and all other CAML oriented files developed in Visual Studio. 
]]></description>
			<content:encoded><![CDATA[<p>From <a href="http://msdn2.microsoft.com/en-us/library/bb507730.aspx" target="_blank">WSS visual How Tos</a>,&nbsp; adding an Xml file for namespace http://schemas.microsoft.com/sharepoint in %ProgramFiels%Microsoft Visual Studio 8XmlSchema directory will bring the intellisense for feature, element manifest, and all other CAML oriented files developed in Visual Studio. </p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jason/2007/12/17/configuring-intellisense-with-caml-files-when-developing-for-wss-3-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CAML Query &lt;And&gt; &lt;Or&gt; can only compare a pair at a time</title>
		<link>http://vspug.com/jason/2007/11/27/caml-query-lt-and-gt-lt-or-gt-can-only-compare-a-pair-at-a-time/</link>
		<comments>http://vspug.com/jason/2007/11/27/caml-query-lt-and-gt-lt-or-gt-can-only-compare-a-pair-at-a-time/#comments</comments>
		<pubDate>Tue, 27 Nov 2007 14:31:00 +0000</pubDate>
		<dc:creator>jasonwj</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[It&#39;s strange that CAML query can only compare a pair of expressions either by &#60;And&#62; or &#60;Or&#62;. So if you have a query like the one follows, you will see an error message &#34;Cannot complete this action. Please try again&#34;, which is not very helpful.
&#60;Where&#62;&#160; &#60;And&#62;&#160;&#160;&#160; &#60;Gt&#62;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;FieldRef Name=&#39;Created&#39; /&#62;&#60;Value Type=&#39;DateTime&#39;&#62;&#60;Today OffsetDays=&#39;-30&#39; /&#62;&#60;/Value&#62;&#160;&#160;&#160; &#60;/Gt&#62;&#160;&#160;&#160; &#60;Neq&#62;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>It&#39;s strange that CAML query can only compare a pair of expressions either by &lt;And&gt; or &lt;Or&gt;. So if you have a query like the one follows, you will see an error message &quot;Cannot complete this action. Please try again&quot;, which is not very helpful.</p>
<p>&lt;Where&gt;<br />&nbsp; &lt;And&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Gt&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FieldRef Name=&#39;Created&#39; /&gt;&lt;Value Type=&#39;DateTime&#39;&gt;&lt;Today OffsetDays=&#39;-30&#39; /&gt;&lt;/Value&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/Gt&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Neq&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FieldRef Name=&#39;ContentType&#39; /&gt;&lt;Value Type=&#39;Text&#39;&gt;Folder&lt;/Value&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/Neq&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Neq&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FieldRef Name=&#39;ContentType&#39; /&gt;&lt;Value Type=&#39;Text&#39;&gt;InfoPath Form Template&lt;/Value&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/Neq&gt;<br />&nbsp; &lt;/And&gt;<br />&lt;/Where&gt;</p>
<p>The workaround is to use nested &lt;And&gt; or &lt;Or&gt;, in which each operator only takes two expressions. The following snippet corrects the above one. This will make things more complicate especially for a number of conditions&nbsp; mixed with &lt;And&gt; and &lt;Or&gt;.</p>
<p>&lt;Where&gt;<br />&nbsp;&lt;And&gt;<br />
&nbsp; &lt;And&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;Gt&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FieldRef Name=&#39;Created&#39; /&gt;&lt;Value Type=&#39;DateTime&#39;&gt;&lt;Today OffsetDays=&#39;-30&#39; /&gt;&lt;/Value&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;/Gt&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;Neq&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FieldRef Name=&#39;ContentType&#39; /&gt;&lt;Value Type=&#39;Text&#39;&gt;Folder&lt;/Value&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;/Neq&gt;<br />&nbsp;&nbsp; &lt;/And&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;Neq&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FieldRef Name=&#39;ContentType&#39; /&gt;&lt;Value Type=&#39;Text&#39;&gt;InfoPath Form Template&lt;/Value&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;/Neq&gt;<br />
&nbsp; &lt;/And&gt;<br />
&lt;/Where&gt; </p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jason/2007/11/27/caml-query-lt-and-gt-lt-or-gt-can-only-compare-a-pair-at-a-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CAML Query &lt;And&gt; &lt;Or&gt; can only compare a pair at a time</title>
		<link>http://vspug.com/jason/2007/11/27/caml-query-lt-and-gt-lt-or-gt-can-only-compare-a-pair-at-a-time/</link>
		<comments>http://vspug.com/jason/2007/11/27/caml-query-lt-and-gt-lt-or-gt-can-only-compare-a-pair-at-a-time/#comments</comments>
		<pubDate>Tue, 27 Nov 2007 14:31:00 +0000</pubDate>
		<dc:creator>jasonwj</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[It&#39;s strange that CAML query can only compare a pair of expressions either by &#60;And&#62; or &#60;Or&#62;. So if you have a query like the one follows, you will see an error message &#34;Cannot complete this action. Please try again&#34;, which is not very helpful.
&#60;Where&#62;&#160; &#60;And&#62;&#160;&#160;&#160; &#60;Gt&#62;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;FieldRef Name=&#39;Created&#39; /&#62;&#60;Value Type=&#39;DateTime&#39;&#62;&#60;Today OffsetDays=&#39;-30&#39; /&#62;&#60;/Value&#62;&#160;&#160;&#160; &#60;/Gt&#62;&#160;&#160;&#160; &#60;Neq&#62;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>It&#39;s strange that CAML query can only compare a pair of expressions either by &lt;And&gt; or &lt;Or&gt;. So if you have a query like the one follows, you will see an error message &quot;Cannot complete this action. Please try again&quot;, which is not very helpful.</p>
<p>&lt;Where&gt;<br />&nbsp; &lt;And&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Gt&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FieldRef Name=&#39;Created&#39; /&gt;&lt;Value Type=&#39;DateTime&#39;&gt;&lt;Today OffsetDays=&#39;-30&#39; /&gt;&lt;/Value&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/Gt&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Neq&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FieldRef Name=&#39;ContentType&#39; /&gt;&lt;Value Type=&#39;Text&#39;&gt;Folder&lt;/Value&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/Neq&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Neq&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FieldRef Name=&#39;ContentType&#39; /&gt;&lt;Value Type=&#39;Text&#39;&gt;InfoPath Form Template&lt;/Value&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/Neq&gt;<br />&nbsp; &lt;/And&gt;<br />&lt;/Where&gt;</p>
<p>The workaround is to use nested &lt;And&gt; or &lt;Or&gt;, in which each operator only takes two expressions. The following snippet corrects the above one. This will make things more complicate especially for a number of conditions&nbsp; mixed with &lt;And&gt; and &lt;Or&gt;.</p>
<p>&lt;Where&gt;<br />&nbsp;&lt;And&gt;<br />
&nbsp; &lt;And&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;Gt&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FieldRef Name=&#39;Created&#39; /&gt;&lt;Value Type=&#39;DateTime&#39;&gt;&lt;Today OffsetDays=&#39;-30&#39; /&gt;&lt;/Value&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;/Gt&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;Neq&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FieldRef Name=&#39;ContentType&#39; /&gt;&lt;Value Type=&#39;Text&#39;&gt;Folder&lt;/Value&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;/Neq&gt;<br />&nbsp;&nbsp; &lt;/And&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;Neq&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FieldRef Name=&#39;ContentType&#39; /&gt;&lt;Value Type=&#39;Text&#39;&gt;InfoPath Form Template&lt;/Value&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;/Neq&gt;<br />
&nbsp; &lt;/And&gt;<br />
&lt;/Where&gt; </p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jason/2007/11/27/caml-query-lt-and-gt-lt-or-gt-can-only-compare-a-pair-at-a-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sort a SPView using code</title>
		<link>http://vspug.com/jason/2007/11/27/sort-a-spview-using-code/</link>
		<comments>http://vspug.com/jason/2007/11/27/sort-a-spview-using-code/#comments</comments>
		<pubDate>Tue, 27 Nov 2007 14:00:00 +0000</pubDate>
		<dc:creator>jasonwj</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[&#160;Long time no blog&#8230;.
My current project with MOSS requires doing almost everything programmatically, provisioning sites, constructing site navigation, creating lists, applying content types, etc. I spent a little while to figure how to sort a SPView for a document library. Once you know it, it&#39;s actually super easy. Just modify the Query property. 
&#160;Example:
&#8230;..SPView view [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;Long time no blog&#8230;.</p>
<p>My current project with MOSS requires doing almost everything programmatically, provisioning sites, constructing site navigation, creating lists, applying content types, etc. I spent a little while to figure how to sort a SPView for a document library. Once you know it, it&#39;s actually super easy. Just modify the Query property. </p>
<p>&nbsp;<br />Example:</p>
<p>&#8230;..<br />SPView view = list.DefaultView;<br />view.Query = &quot;&lt;OrderBy&gt;&lt;FieldRef Name=&#39;Modified&#39; Ascending=&#39;FALSE&#39; /&gt;&lt;/OrderBy&gt;&quot;&#39;<br />&#8230;..</p>
<p>This set the view ordered by the modified date,&nbsp; the newest document at the top. The default order is by document name. Also we can filter the records for this view since it is CAML query string.</p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jason/2007/11/27/sort-a-spview-using-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sort a SPView using code</title>
		<link>http://vspug.com/jason/2007/11/27/sort-a-spview-using-code/</link>
		<comments>http://vspug.com/jason/2007/11/27/sort-a-spview-using-code/#comments</comments>
		<pubDate>Tue, 27 Nov 2007 14:00:00 +0000</pubDate>
		<dc:creator>jasonwj</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[&#160;Long time no blog&#8230;.
My current project with MOSS requires doing almost everything programmatically, provisioning sites, constructing site navigation, creating lists, applying content types, etc. I spent a little while to figure how to sort a SPView for a document library. Once you know it, it&#39;s actually super easy. Just modify the Query property. 
&#160;Example:
&#8230;..SPView view [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;Long time no blog&#8230;.</p>
<p>My current project with MOSS requires doing almost everything programmatically, provisioning sites, constructing site navigation, creating lists, applying content types, etc. I spent a little while to figure how to sort a SPView for a document library. Once you know it, it&#39;s actually super easy. Just modify the Query property. </p>
<p>&nbsp;<br />Example:</p>
<p>&#8230;..<br />SPView view = list.DefaultView;<br />view.Query = &quot;&lt;OrderBy&gt;&lt;FieldRef Name=&#39;Modified&#39; Ascending=&#39;FALSE&#39; /&gt;&lt;/OrderBy&gt;&quot;&#39;<br />&#8230;..</p>
<p>This set the view ordered by the modified date,&nbsp; the newest document at the top. The default order is by document name. Also we can filter the records for this view since it is CAML query string.</p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jason/2007/11/27/sort-a-spview-using-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to connect Web Parts programmatically in WSS 3</title>
		<link>http://vspug.com/jason/2007/06/21/how-to-connect-web-parts-programmatically-in-wss-3/</link>
		<comments>http://vspug.com/jason/2007/06/21/how-to-connect-web-parts-programmatically-in-wss-3/#comments</comments>
		<pubDate>Thu, 21 Jun 2007 18:54:00 +0000</pubDate>
		<dc:creator>jasonwj</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[Web parts are usually connected on the UI as part of customization. There are times better to connect Web parts using code on the fly. For example, we have a site template with a page containing two Web parts working together. Making the connection during site provisioning would be more user friendly. Actually it becomes [...]]]></description>
			<content:encoded><![CDATA[<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman">Web parts are usually connected on the UI as part of customization. There are times better to connect Web parts using code on the fly. For example, we have a site template with a page containing two Web parts working together. Making the connection during site provisioning would be more user friendly. Actually it becomes a must for the template I am working on currently because huge number of sites will be instantiated based on it. Thanks for <a href="http://blogs.msdn.com/edhild/archive/2007/04/17/how-to-connect-web-parts-during-site-provisioning.aspx" target="_blank">edhild&#39;s post</a> giving me great hints and a good start. The following is what I have come up with for this topic.</font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman">Besides WSS 2 Web part, there are two WebPart base classes, ASP.NET WebPart and WSS 3 WebPart, and two sets of connection models, IWebPartXXX in ASP.NET 2/3 and IXXXProvider / IXXXConsumer in WSS 3. Choosing different Web part bases and interfaces will affect the way how to connect them programmatically and how to include them in the site definition. The general rule is using Web part manager to connect Web parts&nbsp;in ASP.NET connection model, using Web parts&#39; Connections property to connect those&nbsp;in WSS connection model. Furthermore, ASP.NET based Web parts cannot be put into a SPWebPartZone in the site template (maybe just I don&#39;t know how). </font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman"><strong>Connecting Web parts in ASP.NET connection medel</strong></font></p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman">As edhild&#39;s post shows, we need SPLimitedWebPartManager to connect the Web parts with ASP.NET style interfaces. The steps for this are:</font></p>
<ol style="MARGIN-TOP:0in;">
<li style="MARGIN:0in 0in 0pt;mso-list:l0 level1 lfo1;tab-stops:list .5in;"><font face="Times New Roman">Get the SPLimitedWebPartManager instance on the page;</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l0 level1 lfo1;tab-stops:list .5in;"><font face="Times New Roman">Get the provider and consumer Web parts need to be connected;</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l0 level1 lfo1;tab-stops:list .5in;"><font face="Times New Roman">Get the connection points for the provider and consumer Web parts;</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l0 level1 lfo1;tab-stops:list .5in;"><font face="Times New Roman">Connect them using SPConnectWebParts method. If necessary, certain transforming needs to be in place for compatible interfaces. </font></li>
</ol>
<p><font face="Times New Roman">&nbsp;</font> <font face="Times New Roman">Code snippet:</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>..</font></font></p>
<p style="MARGIN:0in 0in 0pt;TEXT-INDENT:0.5in;"><font face="Times New Roman">SPWeb web = (SPWeb)properties.Feature.Parent;</font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SPLimitedWebPartManager mgr = web.GetLimitedWebPartManager(&quot;default.aspx&quot;, PersonalizationScope.Shared);</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>System.Web.UI.WebControls.WebParts.WebPart addSearch = mgr.WebParts[&quot;OTAddressSearch&quot;];</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>System.Web.UI.WebControls.WebParts.WebPart addDisplay = mgr.WebParts[&quot;OTAddressDisplay&quot;];</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>ConsumerConnectionPoint addDisplayConnPoint = mgr.GetConsumerConnectionPoints(addDisplay)[&quot;AddressConsumer_ot&quot;];</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>ProviderConnectionPoint addSearchConnPoint = mgr.GetProviderConnectionPoints(addSearch)[&quot;AddressProvider_ot&quot;];</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>mgr.SPConnectWebParts(addSearch, addSearchConnPoint, addDisplay, addDisplayConnPoint);</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman">Some thoughts:</font></p>
<ol style="MARGIN-TOP:0in;">
<li style="MARGIN:0in 0in 0pt;mso-list:l2 level1 lfo2;tab-stops:list .5in;"><font face="Times New Roman">It is preferable to assign the Web part ID property in the template, so that it can be referenced by ID instead of index. Well, I don&#39;t how to assign a list view Web part an ID, but for a custom Web part, the following is a sample:</font></li>
</ol>
<p style="MARGIN:0in 0in 0pt 0.5in;"><font face="Times New Roman">&lt;AllUsersWebPart WebPartZoneID=&quot;Left&quot; WebPartOrder=&quot;1&quot;&gt;</font></p>
<p style="MARGIN:0in 0in 0pt 0.5in;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;![CDATA[&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;WebPart xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns=&quot;http://schemas.microsoft.com/WebPart/v2&quot;&gt;</font></font></p>
<p style="MARGIN:0in 0in 0pt 0.5in;"><font><font face="Times New Roman"><span style="">&nbsp; </span><strong>&lt;ID&gt;OTAddressSearch&lt;/ID&gt;</strong></font></font></p>
<p style="MARGIN:0in 0in 0pt 0.5in;"><font><font face="Times New Roman"><span style="">&nbsp; </span>&lt;Title&gt;Address Search&lt;/Title&gt;</font></font></p>
<p style="MARGIN:0in 0in 0pt 0.5in;"><font><font face="Times New Roman"><span style="">&nbsp; </span>..</font></font></p>
<ol style="MARGIN-TOP:0in;" start="2">
<li style="MARGIN:0in 0in 0pt;mso-list:l2 level1 lfo2;tab-stops:list .5in;"><font face="Times New Roman">The same for the connection point, it is better to reference it by ID. The ID is defined in Web part source code, such as:</font></li>
</ol>
<p style="MARGIN:0in 0in 0pt 0.25in;TEXT-INDENT:0.25in;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>[ConnectionProvider(&quot;Address search criteria&quot;, &quot;<strong>AddressProvider_ot</strong>&quot;)]</font></font></p>
<p style="MARGIN:0in 0in 0pt 0.25in;TEXT-INDENT:0.25in;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>public IWebPartField GetConnectionInterface()</font></font></p>
<p style="MARGIN:0in 0in 0pt 0.25in;TEXT-INDENT:0.25in;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</font></font></p>
<p style="MARGIN:0in 0in 0pt 0.25in;TEXT-INDENT:0.25in;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>return this;</font></font></p>
<p style="MARGIN:0in 0in 0pt 0.25in;TEXT-INDENT:0.25in;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}.</font></font></p>
<ol style="MARGIN-TOP:0in;" start="3">
<li style="MARGIN:0in 0in 0pt;mso-list:l2 level1 lfo2;tab-stops:list .5in;"><font face="Times New Roman">I haven&#39;t figured out how to put a Web part derived from ASP.NET WebPart class into the site template through onet.xml. It is possible to put this type of Web parts onto default.aspx (or other Web part pages), but the user won&#39;t be able to edit them by SharePoint page editing. My approach is to base my Web parts on SharePoint WebPart class, and implement ASP.NET connection interfaces. </font></li>
</ol>
<p><font face="Times New Roman">&nbsp;</font><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman"><strong>Connect Web parts in WSS connection model</strong></font></p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman">If the Web parts use WSS connection model, we should be using a different way to link them. The key idea is to set the Connections property of the consumer Web part, and generally it includes following steps:</font></p>
<ol style="MARGIN-TOP:0in;">
<li style="MARGIN:0in 0in 0pt;mso-list:l1 level1 lfo3;tab-stops:list .5in;"><font face="Times New Roman">Get the SPLimitedWebPartManager instance of the page;</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l1 level1 lfo3;tab-stops:list .5in;"><font face="Times New Roman">Get the provider and consumer Web parts need to be connected, and cast them to WSS WebPart;</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l1 level1 lfo3;tab-stops:list .5in;"><font face="Times New Roman">Assign the Web parts ConnectionID if they don&#39;t have one yet. For a Web part never been connected, this property is an empty GUID.</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l1 level1 lfo3;tab-stops:list .5in;"><font face="Times New Roman">Set the Connections property of the consumer Web part;</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l1 level1 lfo3;tab-stops:list .5in;"><font face="Times New Roman">Save the changes.</font></li>
</ol>
<p><font face="Times New Roman">&nbsp;</font><font face="Times New Roman">Code snippet:</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8230;&#8230;<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SPWeb web = (SPWeb)properties.Feature.Parent;</font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SPLimitedWebPartManager mgr = web.GetLimitedWebPartManager(&quot;default.aspx&quot;, PersonalizationScope.Shared);</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Microsoft.SharePoint.WebPartPages.WebPart imgSearch = (Microsoft.SharePoint.WebPartPages.WebPart)mgr.WebParts[&quot;OTImgSearch&quot;];</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Microsoft.SharePoint.WebPartPages.WebPart imgDisplay = (Microsoft.SharePoint.WebPartPages.WebPart)mgr.WebParts[&quot;OTImgDisplay&quot;];</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (imgSearch.ConnectionID == Guid.Empty)</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>imgSearch.ConnectionID = Guid.NewGuid();</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (imgDisplay.ConnectionID == Guid.Empty)</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>imgDisplay.ConnectionID = Guid.NewGuid();</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>imgDisplay.Connections = imgDisplay.ConnectionID + &quot;,&quot; + <br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>imgSearch.ConnectionID + &quot;,&quot; +<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;MyCellConsumerInterface_WPQ_&quot; + &quot;,&quot; + <br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;MyCellProviderInterface_WPQ_&quot; + &quot;,&quot; + <br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;MyCellConsumerInterface_WPQ_&quot; + &quot;,&quot; + <br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;MyCellProviderInterface_WPQ_&quot;;</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>mgr.SaveChanges(imgSearch);</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>mgr.SaveChanges(imgDisplay);</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman">Some thoughts:</font></p>
<ol style="MARGIN-TOP:0in;">
<li style="MARGIN:0in 0in 0pt;mso-list:l3 level1 lfo4;tab-stops:list .5in;"><font face="Times New Roman">Refer the <a href="https://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.webpart.connections.aspx" target="_blank">msdn for details about the Connections</a> property. The above example only shows the simplest case, connecting Web parts that implement ICellProvider and ICellConsumer interfaces.</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l3 level1 lfo4;tab-stops:list .5in;"><font face="Times New Roman">We need the connection point ID for the two Web parts. They are defined in the RegisterInterface() method, e.g.:</font></li>
</ol>
<p style="MARGIN:0in 0in 0pt 0.5in;"><font><font face="Times New Roman">RegisterInterface(&quot;<strong>MyCellConsumerInterface_WPQ_</strong>&quot;,<span style="">&nbsp;&nbsp; </span>//InterfaceName<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>InterfaceTypes.ICellConsumer,<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>//InterfaceType<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>WebPart.UnlimitedConnections,<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;</span><span style="">&nbsp;</span>//MaxConnections<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>ConnectionRunAt.ServerAndClient,<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//RunAtOptions<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>this,<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;</span>//InterfaceObject<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;CellConsumerInterface_WPQ_&quot;,<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//InterfaceClientReference<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;Get String Value&quot;,<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;</span>//MenuLabel<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;Just a simple ICellConsumer&quot;);<span style="">&nbsp;&nbsp;&nbsp; </span></font></font></p>
<p style="MARGIN:0in 0in 0pt 0.5in;"><font><font face="Times New Roman"><span style=""></span></font></font>&nbsp;</p>
<p><font face="Times New Roman">Next step is to put the code into proper site provisioning event. If the Visual Studio site definition project template <a href="/jason/archive/2007/03/12/sharepoint-project-templates-amp-amp-sharepoint-solution-package.aspx" target="_blank">happens to be enough</a> for your needs, then simply put them into the place MS reserved for developers &#8211; the OnActivated method. For those who make their own SharePoint solutions, just like me, we need to define a feature, include this feature in the site definition, and put the code in the feature receiver&#39;s FeatureActivated event. One thing I noticed is that, the default site home page (default.aspx) should be defined as an element file as this feature, not defined in the site definition (in site template folder together with the onet.xml file). Otherwise, I got the file not found error when opening the page to get the Web part manager instance. I am guessing this is because the page defined in site definition is instantiated after the feature activation. Anyway, making it as an element file does not bother me since I will have to define many other Web part pages along with this feature. </font></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jason/2007/06/21/how-to-connect-web-parts-programmatically-in-wss-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to connect Web Parts programmatically in WSS 3</title>
		<link>http://vspug.com/jason/2007/06/21/how-to-connect-web-parts-programmatically-in-wss-3/</link>
		<comments>http://vspug.com/jason/2007/06/21/how-to-connect-web-parts-programmatically-in-wss-3/#comments</comments>
		<pubDate>Thu, 21 Jun 2007 18:54:00 +0000</pubDate>
		<dc:creator>jasonwj</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[Web parts are usually connected on the UI as part of customization. There are times better to connect Web parts using code on the fly. For example, we have a site template with a page containing two Web parts working together. Making the connection during site provisioning would be more user friendly. Actually it becomes [...]]]></description>
			<content:encoded><![CDATA[<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman">Web parts are usually connected on the UI as part of customization. There are times better to connect Web parts using code on the fly. For example, we have a site template with a page containing two Web parts working together. Making the connection during site provisioning would be more user friendly. Actually it becomes a must for the template I am working on currently because huge number of sites will be instantiated based on it. Thanks for <a href="http://blogs.msdn.com/edhild/archive/2007/04/17/how-to-connect-web-parts-during-site-provisioning.aspx" target="_blank">edhild&#39;s post</a> giving me great hints and a good start. The following is what I have come up with for this topic.</font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman">Besides WSS 2 Web part, there are two WebPart base classes, ASP.NET WebPart and WSS 3 WebPart, and two sets of connection models, IWebPartXXX in ASP.NET 2/3 and IXXXProvider / IXXXConsumer in WSS 3. Choosing different Web part bases and interfaces will affect the way how to connect them programmatically and how to include them in the site definition. The general rule is using Web part manager to connect Web parts&nbsp;in ASP.NET connection model, using Web parts&#39; Connections property to connect those&nbsp;in WSS connection model. Furthermore, ASP.NET based Web parts cannot be put into a SPWebPartZone in the site template (maybe just I don&#39;t know how). </font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman"><strong>Connecting Web parts in ASP.NET connection medel</strong></font></p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman">As edhild&#39;s post shows, we need SPLimitedWebPartManager to connect the Web parts with ASP.NET style interfaces. The steps for this are:</font></p>
<ol style="MARGIN-TOP:0in;">
<li style="MARGIN:0in 0in 0pt;mso-list:l0 level1 lfo1;tab-stops:list .5in;"><font face="Times New Roman">Get the SPLimitedWebPartManager instance on the page;</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l0 level1 lfo1;tab-stops:list .5in;"><font face="Times New Roman">Get the provider and consumer Web parts need to be connected;</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l0 level1 lfo1;tab-stops:list .5in;"><font face="Times New Roman">Get the connection points for the provider and consumer Web parts;</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l0 level1 lfo1;tab-stops:list .5in;"><font face="Times New Roman">Connect them using SPConnectWebParts method. If necessary, certain transforming needs to be in place for compatible interfaces. </font></li>
</ol>
<p><font face="Times New Roman">&nbsp;</font> <font face="Times New Roman">Code snippet:</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>..</font></font></p>
<p style="MARGIN:0in 0in 0pt;TEXT-INDENT:0.5in;"><font face="Times New Roman">SPWeb web = (SPWeb)properties.Feature.Parent;</font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SPLimitedWebPartManager mgr = web.GetLimitedWebPartManager(&quot;default.aspx&quot;, PersonalizationScope.Shared);</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>System.Web.UI.WebControls.WebParts.WebPart addSearch = mgr.WebParts[&quot;OTAddressSearch&quot;];</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>System.Web.UI.WebControls.WebParts.WebPart addDisplay = mgr.WebParts[&quot;OTAddressDisplay&quot;];</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>ConsumerConnectionPoint addDisplayConnPoint = mgr.GetConsumerConnectionPoints(addDisplay)[&quot;AddressConsumer_ot&quot;];</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>ProviderConnectionPoint addSearchConnPoint = mgr.GetProviderConnectionPoints(addSearch)[&quot;AddressProvider_ot&quot;];</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>mgr.SPConnectWebParts(addSearch, addSearchConnPoint, addDisplay, addDisplayConnPoint);</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman">Some thoughts:</font></p>
<ol style="MARGIN-TOP:0in;">
<li style="MARGIN:0in 0in 0pt;mso-list:l2 level1 lfo2;tab-stops:list .5in;"><font face="Times New Roman">It is preferable to assign the Web part ID property in the template, so that it can be referenced by ID instead of index. Well, I don&#39;t how to assign a list view Web part an ID, but for a custom Web part, the following is a sample:</font></li>
</ol>
<p style="MARGIN:0in 0in 0pt 0.5in;"><font face="Times New Roman">&lt;AllUsersWebPart WebPartZoneID=&quot;Left&quot; WebPartOrder=&quot;1&quot;&gt;</font></p>
<p style="MARGIN:0in 0in 0pt 0.5in;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;![CDATA[&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;WebPart xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns=&quot;http://schemas.microsoft.com/WebPart/v2&quot;&gt;</font></font></p>
<p style="MARGIN:0in 0in 0pt 0.5in;"><font><font face="Times New Roman"><span style="">&nbsp; </span><strong>&lt;ID&gt;OTAddressSearch&lt;/ID&gt;</strong></font></font></p>
<p style="MARGIN:0in 0in 0pt 0.5in;"><font><font face="Times New Roman"><span style="">&nbsp; </span>&lt;Title&gt;Address Search&lt;/Title&gt;</font></font></p>
<p style="MARGIN:0in 0in 0pt 0.5in;"><font><font face="Times New Roman"><span style="">&nbsp; </span>..</font></font></p>
<ol style="MARGIN-TOP:0in;" start="2">
<li style="MARGIN:0in 0in 0pt;mso-list:l2 level1 lfo2;tab-stops:list .5in;"><font face="Times New Roman">The same for the connection point, it is better to reference it by ID. The ID is defined in Web part source code, such as:</font></li>
</ol>
<p style="MARGIN:0in 0in 0pt 0.25in;TEXT-INDENT:0.25in;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>[ConnectionProvider(&quot;Address search criteria&quot;, &quot;<strong>AddressProvider_ot</strong>&quot;)]</font></font></p>
<p style="MARGIN:0in 0in 0pt 0.25in;TEXT-INDENT:0.25in;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>public IWebPartField GetConnectionInterface()</font></font></p>
<p style="MARGIN:0in 0in 0pt 0.25in;TEXT-INDENT:0.25in;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</font></font></p>
<p style="MARGIN:0in 0in 0pt 0.25in;TEXT-INDENT:0.25in;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>return this;</font></font></p>
<p style="MARGIN:0in 0in 0pt 0.25in;TEXT-INDENT:0.25in;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}.</font></font></p>
<ol style="MARGIN-TOP:0in;" start="3">
<li style="MARGIN:0in 0in 0pt;mso-list:l2 level1 lfo2;tab-stops:list .5in;"><font face="Times New Roman">I haven&#39;t figured out how to put a Web part derived from ASP.NET WebPart class into the site template through onet.xml. It is possible to put this type of Web parts onto default.aspx (or other Web part pages), but the user won&#39;t be able to edit them by SharePoint page editing. My approach is to base my Web parts on SharePoint WebPart class, and implement ASP.NET connection interfaces. </font></li>
</ol>
<p><font face="Times New Roman">&nbsp;</font><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman"><strong>Connect Web parts in WSS connection model</strong></font></p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman">If the Web parts use WSS connection model, we should be using a different way to link them. The key idea is to set the Connections property of the consumer Web part, and generally it includes following steps:</font></p>
<ol style="MARGIN-TOP:0in;">
<li style="MARGIN:0in 0in 0pt;mso-list:l1 level1 lfo3;tab-stops:list .5in;"><font face="Times New Roman">Get the SPLimitedWebPartManager instance of the page;</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l1 level1 lfo3;tab-stops:list .5in;"><font face="Times New Roman">Get the provider and consumer Web parts need to be connected, and cast them to WSS WebPart;</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l1 level1 lfo3;tab-stops:list .5in;"><font face="Times New Roman">Assign the Web parts ConnectionID if they don&#39;t have one yet. For a Web part never been connected, this property is an empty GUID.</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l1 level1 lfo3;tab-stops:list .5in;"><font face="Times New Roman">Set the Connections property of the consumer Web part;</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l1 level1 lfo3;tab-stops:list .5in;"><font face="Times New Roman">Save the changes.</font></li>
</ol>
<p><font face="Times New Roman">&nbsp;</font><font face="Times New Roman">Code snippet:</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8230;&#8230;<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SPWeb web = (SPWeb)properties.Feature.Parent;</font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SPLimitedWebPartManager mgr = web.GetLimitedWebPartManager(&quot;default.aspx&quot;, PersonalizationScope.Shared);</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Microsoft.SharePoint.WebPartPages.WebPart imgSearch = (Microsoft.SharePoint.WebPartPages.WebPart)mgr.WebParts[&quot;OTImgSearch&quot;];</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Microsoft.SharePoint.WebPartPages.WebPart imgDisplay = (Microsoft.SharePoint.WebPartPages.WebPart)mgr.WebParts[&quot;OTImgDisplay&quot;];</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (imgSearch.ConnectionID == Guid.Empty)</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>imgSearch.ConnectionID = Guid.NewGuid();</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (imgDisplay.ConnectionID == Guid.Empty)</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>imgDisplay.ConnectionID = Guid.NewGuid();</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>imgDisplay.Connections = imgDisplay.ConnectionID + &quot;,&quot; + <br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>imgSearch.ConnectionID + &quot;,&quot; +<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;MyCellConsumerInterface_WPQ_&quot; + &quot;,&quot; + <br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;MyCellProviderInterface_WPQ_&quot; + &quot;,&quot; + <br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;MyCellConsumerInterface_WPQ_&quot; + &quot;,&quot; + <br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;MyCellProviderInterface_WPQ_&quot;;</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>mgr.SaveChanges(imgSearch);</font></font></p>
<p style="MARGIN:0in 0in 0pt;"><font><font face="Times New Roman"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>mgr.SaveChanges(imgDisplay);</font></font></p>
<p><font face="Times New Roman">&nbsp;</font> </p>
<p style="MARGIN:0in 0in 0pt;"><font face="Times New Roman">Some thoughts:</font></p>
<ol style="MARGIN-TOP:0in;">
<li style="MARGIN:0in 0in 0pt;mso-list:l3 level1 lfo4;tab-stops:list .5in;"><font face="Times New Roman">Refer the <a href="https://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.webpart.connections.aspx" target="_blank">msdn for details about the Connections</a> property. The above example only shows the simplest case, connecting Web parts that implement ICellProvider and ICellConsumer interfaces.</font></li>
<li style="MARGIN:0in 0in 0pt;mso-list:l3 level1 lfo4;tab-stops:list .5in;"><font face="Times New Roman">We need the connection point ID for the two Web parts. They are defined in the RegisterInterface() method, e.g.:</font></li>
</ol>
<p style="MARGIN:0in 0in 0pt 0.5in;"><font><font face="Times New Roman">RegisterInterface(&quot;<strong>MyCellConsumerInterface_WPQ_</strong>&quot;,<span style="">&nbsp;&nbsp; </span>//InterfaceName<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>InterfaceTypes.ICellConsumer,<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>//InterfaceType<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>WebPart.UnlimitedConnections,<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;</span><span style="">&nbsp;</span>//MaxConnections<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>ConnectionRunAt.ServerAndClient,<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//RunAtOptions<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>this,<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;</span>//InterfaceObject<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;CellConsumerInterface_WPQ_&quot;,<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//InterfaceClientReference<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;Get String Value&quot;,<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;</span>//MenuLabel<br /><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&quot;Just a simple ICellConsumer&quot;);<span style="">&nbsp;&nbsp;&nbsp; </span></font></font></p>
<p style="MARGIN:0in 0in 0pt 0.5in;"><font><font face="Times New Roman"><span style=""></span></font></font>&nbsp;</p>
<p><font face="Times New Roman">Next step is to put the code into proper site provisioning event. If the Visual Studio site definition project template <a href="/jason/archive/2007/03/12/sharepoint-project-templates-amp-amp-sharepoint-solution-package.aspx" target="_blank">happens to be enough</a> for your needs, then simply put them into the place MS reserved for developers &#8211; the OnActivated method. For those who make their own SharePoint solutions, just like me, we need to define a feature, include this feature in the site definition, and put the code in the feature receiver&#39;s FeatureActivated event. One thing I noticed is that, the default site home page (default.aspx) should be defined as an element file as this feature, not defined in the site definition (in site template folder together with the onet.xml file). Otherwise, I got the file not found error when opening the page to get the Web part manager instance. I am guessing this is because the page defined in site definition is instantiated after the feature activation. Anyway, making it as an element file does not bother me since I will have to define many other Web part pages along with this feature. </font></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jason/2007/06/21/how-to-connect-web-parts-programmatically-in-wss-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tricks for debugging Web Parts and Web pages in SharePoint</title>
		<link>http://vspug.com/jason/2007/05/14/tricks-for-debugging-web-parts-and-web-pages-in-sharepoint/</link>
		<comments>http://vspug.com/jason/2007/05/14/tricks-for-debugging-web-parts-and-web-pages-in-sharepoint/#comments</comments>
		<pubDate>Tue, 15 May 2007 02:24:00 +0000</pubDate>
		<dc:creator>jasonwj</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[I&#160;decide to make this post as an ongoing one to record the tricks I come up with for debugging Web Parts and Web Part pages in ShaePoint.
1. Show call stack if exception occurs. Pages in SharePoint show&#160;&#34;user friendly&#34; messages when exception occurs. Often the messages are meaningless to developers. On the other hand the call [...]]]></description>
			<content:encoded><![CDATA[<p>I&nbsp;decide to make this post as an ongoing one to record the tricks I come up with for debugging Web Parts and Web Part pages in ShaePoint.</p>
<p>1. <strong>Show call stack if exception occurs</strong>. Pages in SharePoint show&nbsp;&quot;user friendly&quot; messages when exception occurs. Often the messages are meaningless to developers. On the other hand the call stack on a normal aspx page upon exception is useful to determin where and what is wrong. So in the course of development, turn it on for SharePoint pages is a good choice.</p>
<p>&nbsp;&nbsp; How: find the tag &lt;configuration&gt;&lt;SharePoint&gt;&lt;SafeMode&gt;, set the attribute&nbsp;as&nbsp;CallStack=&quot;true&quot;</p>
<p>2. <strong>Write in-line code block&nbsp;for easy debug</strong>. On an&nbsp;ASP.NET page, writing in-line code block is usually convenient&nbsp;especially with the full intellisense. After testing and debug, we can&nbsp;simply move the code block&nbsp;into the partial page class (<a href="http://authors.aspalliance.com/PaulWilson/Articles/?id=19" target="_blank">code beside</a>) and deploy it into GAC. However, SharePoint does now allow the code block on pages, unless we&nbsp;modify the web.config. </p>
<p>&nbsp;&nbsp; How: in tag &lt;configuration&gt;&lt;SharePoint&gt;&lt;SafeMode&gt;&lt;PageParserPaths&gt;, add entry to allow the page contains code block, i.e. &lt;PageParserPath VirtualPath=&quot;/list/matters/myitems.aspx&quot; CompilationMode=&quot;Always&quot; AllowServerSideScript=&quot;true&quot; /&gt;</p>
<p>&nbsp;&nbsp; For details, see <a href="http://weblogs.asp.net/soever/archive/2006/07/27/SharePoint-2007_3A00_-using-ASP.NET-server-side-code-in-your-pages.aspx" target="_blank">Serge&#39;s nice post</a>. </p>
<p>&nbsp;</p>
<p><img height="1" src="/aggbug.aspx?PostID=26010" width="1" alt="  " /></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jason/2007/05/14/tricks-for-debugging-web-parts-and-web-pages-in-sharepoint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tricks for debugging Web Parts and Web pages in SharePoint</title>
		<link>http://vspug.com/jason/2007/05/14/tricks-for-debugging-web-parts-and-web-pages-in-sharepoint/</link>
		<comments>http://vspug.com/jason/2007/05/14/tricks-for-debugging-web-parts-and-web-pages-in-sharepoint/#comments</comments>
		<pubDate>Tue, 15 May 2007 02:24:00 +0000</pubDate>
		<dc:creator>jasonwj</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[I&#160;decide to make this post as an ongoing one to record the tricks I come up with for debugging Web Parts and Web Part pages in ShaePoint.
1. Show call stack if exception occurs. Pages in SharePoint show&#160;&#34;user friendly&#34; messages when exception occurs. Often the messages are meaningless to developers. On the other hand the call [...]]]></description>
			<content:encoded><![CDATA[<p>I&nbsp;decide to make this post as an ongoing one to record the tricks I come up with for debugging Web Parts and Web Part pages in ShaePoint.</p>
<p>1. <strong>Show call stack if exception occurs</strong>. Pages in SharePoint show&nbsp;&quot;user friendly&quot; messages when exception occurs. Often the messages are meaningless to developers. On the other hand the call stack on a normal aspx page upon exception is useful to determin where and what is wrong. So in the course of development, turn it on for SharePoint pages is a good choice.</p>
<p>&nbsp;&nbsp; How: find the tag &lt;configuration&gt;&lt;SharePoint&gt;&lt;SafeMode&gt;, set the attribute&nbsp;as&nbsp;CallStack=&quot;true&quot;</p>
<p>2. <strong>Write in-line code block&nbsp;for easy debug</strong>. On an&nbsp;ASP.NET page, writing in-line code block is usually convenient&nbsp;especially with the full intellisense. After testing and debug, we can&nbsp;simply move the code block&nbsp;into the partial page class (<a href="http://authors.aspalliance.com/PaulWilson/Articles/?id=19" target="_blank">code beside</a>) and deploy it into GAC. However, SharePoint does now allow the code block on pages, unless we&nbsp;modify the web.config. </p>
<p>&nbsp;&nbsp; How: in tag &lt;configuration&gt;&lt;SharePoint&gt;&lt;SafeMode&gt;&lt;PageParserPaths&gt;, add entry to allow the page contains code block, i.e. &lt;PageParserPath VirtualPath=&quot;/list/matters/myitems.aspx&quot; CompilationMode=&quot;Always&quot; AllowServerSideScript=&quot;true&quot; /&gt;</p>
<p>&nbsp;&nbsp; For details, see <a href="http://weblogs.asp.net/soever/archive/2006/07/27/SharePoint-2007_3A00_-using-ASP.NET-server-side-code-in-your-pages.aspx" target="_blank">Serge&#39;s nice post</a>. </p>
<p>&nbsp;</p>
<p><img height="1" src="/aggbug.aspx?PostID=26010" width="1" alt="  " /></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jason/2007/05/14/tricks-for-debugging-web-parts-and-web-pages-in-sharepoint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
