<?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>SPSherm.MyBlog &#187; Web Parts</title>
	<atom:link href="http://spsherm.uptempoconsulting.com/tag/web-parts/feed/" rel="self" type="application/rss+xml" />
	<link>http://spsherm.uptempoconsulting.com</link>
	<description>SharePoint, of course.</description>
	<lastBuildDate>Mon, 03 Oct 2011 03:01:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Custom Web Parts can &#8220;break&#8221; Variations process.</title>
		<link>http://spsherm.uptempoconsulting.com/2007/10/custom-web-parts-can-break-variations-process/</link>
		<comments>http://spsherm.uptempoconsulting.com/2007/10/custom-web-parts-can-break-variations-process/#comments</comments>
		<pubDate>Wed, 24 Oct 2007 19:39:24 +0000</pubDate>
		<dc:creator>Sherman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SP2007]]></category>
		<category><![CDATA[Variations]]></category>
		<category><![CDATA[Web Parts]]></category>

		<guid isPermaLink="false">http://spsherm.uptempoconsulting.com/?p=133</guid>
		<description><![CDATA[Ok, the title is vague, but there&#8217;s only so much I can put in a title, right? As per MSDN&#8217;s documentation for the Microsoft.SharePoint.WebPartPages class and Andrew&#8217;s post on v3 web parts, we should now inherit from System.Web.UI.WebControls.WebParts.WebPart when we are building custom web parts, except in the four scenarios he mentions (repeating here for my [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, the title is vague, but there&#8217;s only so much I can put in a title, right? <img src='http://www.uptempoconsulting.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>As per MSDN&#8217;s documentation for the <a href="http://msdn2.microsoft.com/en-us/library/ms461685.aspx" target="_blank">Microsoft.SharePoint.WebPartPages</a> class and <a href="http://andrewconnell.com/blog/archive/2006/05/20/3131.aspx" target="_blank">Andrew&#8217;s post on v3 web parts</a>, we should now inherit from <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webpart(VS.80).aspx" target="_blank">System.Web.UI.WebControls.WebParts.WebPart</a> when we are building custom web parts, <em>except </em>in the four scenarios he mentions (repeating here for my own records):</p>
<ol>
<li>Cross page connections</li>
<li>Connections between Web Parts that are outside of a Web Part zone</li>
<li>Client-side connections (Web Part Page Services Component)</li>
<li>A data caching infrastructure that allows caching to the content database</li>
</ol>
<p>However, I came across a situation recently whereby a very simple custom web part (all it did was render a &#8220;Get Adobe Acrobat&#8221; link, essentially) threw a SharePoint error to the screen when used in conjunction with Variations. Here&#8217;s the steps to replicate:</p>
<ol>
<li>
<div>Create your custom web part, inheriting from <code>System.Web.UI.WebControls.WebParts.WebPart</code>. Keep it simple; &#8220;Hello World&#8221; is fine.</div>
</li>
<li>
<div>Build/deploy, etc. Use it in one of your page layouts. Of course, Variations has to be set up/enabled, <strong>but turn off automatic creation of target pages</strong>.</div>
</li>
<li>
<div>Once the new page has been created, select either &#8220;Update Variations&#8221; from the Tools menu.</div>
</li>
<li>
<div>SharePoint will start a long running operation, and then eventually throw an error to the screen.</div>
</li>
<li>
<div>The target variation page is actually created, but this error message is annoying, and probably discomforting to the authors.</div>
</li>
</ol>
<p>It took me a while to figure out what was causing the problem. I finally had a thorough look in the SharePoint logs, and found the message that told me the cause. If you are using <a href="http://www.spsdev.com/ulsreader.aspx" target="_blank">SpsDev&#8217;s ULS Log Reader</a>, filter by Area:CMS, Category:Publishing, or just look for the message &#8220;Unable to cast&#8221;. The relevant part of the message is:</p>
<p><code>Unable to cast object of type '******.Website.SharePoint.WebParts.AdobeLinkWebPart' to type 'Microsoft.SharePoint.WebPartPages.WebPart'</code></p>
<p>Um, what? Why does it want to do that? So&#8230;</p>
<ol>
<li>
<div>Re-write the web part to inherit from <code>Microsoft.SharePoint.WebPartPages.WebPart</code>.</div>
</li>
<li>
<div>Create a new DWP file to match.</div>
</li>
<li>
<div>Deploy, etc; re-test.</div>
</li>
<li>
<div>Of course, it works without the error.</div>
</li>
</ol>
<p>Microsoft&#8217;s own web parts that inherit from <code>System.Web.UI.WebControls.WebParts.WebPart</code> don&#8217;t seem to have the same behaviour. Nevertheless, I believe this to be a bug, but one that you should know about when using custom web parts in conjunction with Variations.</p>
]]></content:encoded>
			<wfw:commentRss>http://spsherm.uptempoconsulting.com/2007/10/custom-web-parts-can-break-variations-process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

