<?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>Buta no Ie &#187; custom</title>
	<atom:link href="http://singchan.com/tag/custom/feed/" rel="self" type="application/rss+xml" />
	<link>http://singchan.com</link>
	<description>The House of Pork and User Experience Development</description>
	<lastBuildDate>Sat, 31 Jul 2010 21:49:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>SharePoint 2010: Fixing the MSDN Contextual Tab Web Part Walkthrough</title>
		<link>http://singchan.com/2010/07/31/sharepoint-2010-fixing-the-msdn-contextual-tab-web-part-walkthrough/</link>
		<comments>http://singchan.com/2010/07/31/sharepoint-2010-fixing-the-msdn-contextual-tab-web-part-walkthrough/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 21:49:54 +0000</pubDate>
		<dc:creator>Buta</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Ribbon]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Web Part]]></category>
		<category><![CDATA[2010]]></category>
		<category><![CDATA[contextual tab]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[ribbon]]></category>
		<category><![CDATA[ue]]></category>
		<category><![CDATA[user experience]]></category>
		<category><![CDATA[web part]]></category>

		<guid isPermaLink="false">http://singchan.com/?p=268</guid>
		<description><![CDATA[I haven&#8217;t had much opportunity to work with SharePoint 2010 in the past few months. However, I did get to try out the MSDN walkthrough for creating a custom web part with contextual ribbon tab recently. You can find the article here: http://msdn.microsoft.com/en-us/library/ff407578.aspx In a nutshell, what&#8217;s supposed to happen is when you click on [...]]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t had much opportunity to work with SharePoint 2010 in the past few months. However, I did get to try out the MSDN walkthrough for creating a custom web part with contextual ribbon tab recently. You can find the article here: <a href="http://msdn.microsoft.com/en-us/library/ff407578.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/ff407578.aspx</a></p>
<p>In a nutshell, what&#8217;s supposed to happen is when you click on the web part, there will be a custom tab that appears in the Ribbon. It all works great for the first instance of the custom web part you place onto a page, but if you try adding a second instance of the web part, your page blows up!</p>
<p>You&#8217;ll get the following error:<br />
<em>Item has already been added. Key in dictionary: &#8216;Ribbon.CustomContextualTabGroup&#8217;  Key being added: &#8216;Ribbon.CustomContextualTabGroup&#8217;</em></p>
<p>:-/ &#8230; looks like there wasn&#8217;t much QA done for the walkthrough. Anyways, to make a short story shorter&#8230; I posted a question on the <a href="http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/8604fda5-dad3-49e5-b820-af98ae2fb3cf" target="_blank">TechNet forums</a> and Dallas Tester from MS did get back to me with a bunch of suggestions.</p>
<p>Here are the changes you can make to allow for multiple instances of the custom web part to appear on the page without everything blowing up.</p>
<p><strong>Make the following modifications to the ContextualTabWebPart class.</strong></p>
<p>Add the global &#8216;_added&#8217; bool and OnInit event handler:</p>
<pre class="brush: csharp;">static bool _added = false;

protected override void OnInit(EventArgs e)
{
 base.OnInit(e);
 _added = false;
}</pre>
<p>Since we no longer have to get the unique component ID in the delay script, I changed DelayScript into a private string:</p>
<pre class="brush: csharp;">private string delayScript = @&quot;
 function _addCustomPageComponent()
 {
  for (var i = 0; i &lt; g_customWebPartIds.length; i++)
  {
    SP.Ribbon.PageManager.get_instance().addPageComponent(new ContextualTabWebPart.CustomPageComponent(g_customWebPartIds[i]));
  }
 }

 function _registerCustomPageComponent()
 {
  SP.SOD.registerSod(&quot;&quot;CustomContextualTabPageComponent.js&quot;&quot;, &quot;&quot;/_layouts/CustomContextualTabPageComponent.js&quot;&quot;);
  var isDefined = &quot;&quot;undefined&quot;&quot;;
  try
  {
   isDefined = typeof(ContextualTabWebPart.CustomPageComponent);
  }
  catch(e)
  {
  }
  EnsureScript(&quot;&quot;CustomContextualTabPageComponent.js&quot;&quot;,isDefined, _addCustomPageComponent);
 }
 SP.SOD.executeOrDelayUntilScriptLoaded(_registerCustomPageComponent, &quot;&quot;sp.ribbon.js&quot;&quot;);&quot;;</pre>
<p>Modify the OnPreRender event handler:</p>
<pre class="brush: csharp;">protected override void OnPreRender(EventArgs e)
{
 base.OnPreRender(e);

 ClientScriptManager csm = this.Page.ClientScript;
 string componentId = SPRibbon.GetWebPartPageComponentId(this); // the unique component id 

 // if this is the first instance of the custom web part,
 //we need to add the contextual tab to the ribbon
 if (!_added)
 {
  this.AddContextualTab();
  _added = true;
 }

 // we need to create an array which will store the IDs of all instances of our custom web part
 csm.RegisterClientScriptBlock(
  this.GetType(), &quot;DeclareCustomWebPartArray&quot;, &quot;var g_customWebPartIds = new Array();&quot;, true);

 // add this webpart's ID to our array
 csm.RegisterClientScriptBlock(
  this.GetType(), &quot;AddCustomWebPartId&quot; + componentId, &quot;g_customWebPartIds.push('&quot; + componentId + &quot;');&quot;, true);

 csm.RegisterClientScriptBlock(this.GetType(), &quot;ContextualTabWebPart&quot;, this.delayScript, true);
}</pre>
<p><strong>If you want to verify that the correct web part is trigger the Ribbon commands, you can modify the &#8216;<em>handleCommand</em>&#8216; method in &#8216;<em>CustomContextualTabPageComponent.js</em>&#8216;</strong></p>
<pre class="brush: jscript;">handleCommand: function ContextualTabWebPart_CustomPageComponent$handleCommand(commandId, properties, sequence) {
 if (commandId === 'CustomContextualTab.HelloWorldCommand') {
  alert(this._webPartPageComponentId + ' says: Hello, world!');
 }
 if (commandId === 'CustomContextualTab.GoodbyeWorldCommand') {
  alert(this._webPartPageComponentId + ' says: Good-bye, world!');
 }
}</pre>
<p>Here&#8217;s a <a href="http://singchan.com/wordpress/wp-content/uploads/2010/07/ContextualTabWebPart.zip">ZIP file of the entire solution</a> in case you&#8217;re too lazy to make the modifications yourself. <img src='http://singchan.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://singchan.com/2010/07/31/sharepoint-2010-fixing-the-msdn-contextual-tab-web-part-walkthrough/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Branding SharePoint 2010 Collaboration Sites &#8211; Part 3 in a Series</title>
		<link>http://singchan.com/2010/02/23/branding-sharepoint-2010-collaboration-sites-part-3-in-a-series/</link>
		<comments>http://singchan.com/2010/02/23/branding-sharepoint-2010-collaboration-sites-part-3-in-a-series/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 16:04:48 +0000</pubDate>
		<dc:creator>Buta</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[2010]]></category>
		<category><![CDATA[collaboration]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[DelegateControl]]></category>
		<category><![CDATA[master page]]></category>
		<category><![CDATA[SPC09]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[theming system]]></category>
		<category><![CDATA[ue]]></category>
		<category><![CDATA[user experience]]></category>

		<guid isPermaLink="false">http://singchan.com/?p=181</guid>
		<description><![CDATA[In part two, we posted about how to register our custom style sheets in a way that we could still take advantage of the new SharePoint 2010 colour switching theming engine. In this post we&#8217;ll go through how to do this without having to modify the out-of-the-box master pages or having to use custom master [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://singchan.com/2009/12/29/branding-sharepoint-2010-collaboration-sites-part-2-in-a-series/" title="Branding SharePoint 2010 Collaboration Sites - Part 2 in a Series">part two</a>, we posted about how to register our custom style sheets in a way that we could still take advantage of the new SharePoint 2010 colour switching theming engine. In this post we&#8217;ll go through how to do this without having to modify the out-of-the-box master pages or having to use custom master pages for your sites.</p>
<h3>Delegate Controls</h3>
<p>As I mentioned at the end of part two, the way we&#8217;re going to get our CSS added to our sites and pages is through the use of a <strong>delegate control</strong>. For those of you who aren&#8217;t familiar with delegate controls, they are essentially placeholders for you to inject your own controls via a feature. Your feature can be scoped to either <em>Web</em>, <em>Site</em>, <em>WebApplication</em> or <em>Farm</em>. I&#8217;m going to keep the explanation on delegate controls short as there&#8217;s plenty of information out there about them:</p>
<ul>
<li><a href="http://www.sharepointnutsandbolts.com/2007/06/using-delegate-control.html">Chris O&#8217;Brien: Using the Delegate Control</a></li>
<li><a href="http://www.devx.com/enterprise/Article/36628/1954">SharePoint&#8217;s Delegate Control Power</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.delegatecontrol%28office.14%29.aspx">MSDN 2010 SDK: DelegateControl Class</a></li>
</ul>
<div id="attachment_204" class="wp-caption alignright" style="width: 160px"><a href="http://singchan.com/wordpress/wp-content/uploads/2010/02/AdditionalPageHead.png" rel="lightbox[181]" title="AdditionalPageHead Delegate Control"><img src="http://singchan.com/wordpress/wp-content/uploads/2010/02/AdditionalPageHead-150x150.png" alt="Screenshot of AdditionalPageHead delegate control in v4.master" title="AdditionalPageHead Delegate Control" width="150" height="150" class="size-thumbnail wp-image-204" /></a><p class="wp-caption-text">AdditionalPageHead Delegate Control</p></div>
<h3>The AdditionalPageHead Delegate</h3>
<p>Delegate controls have a <strong>AllowMultipleControls</strong> property which when set to <em>true</em>, all controls keyed to that delegate are added to the page; when set to <em>false</em>, only the control registered with the lowest <em>sequence</em> value is added to the page.</p>
<p>All of the delegate controls in the OOTB master pages have <strong>AllowMultipleControls</strong> set to <em>false</em>, with the exception of one, <strong>AdditionalPageHead</strong>, which does allow multiple controls. And guess what? AdditionalPageHead is actually located in the page head, where you would normally add CSS
<link> elements! This is the perfect place for us to inject any CSS registration controls.</p>
<h3>Putting it all together&#8230;</h3>
<p>Let&#8217;s put together a simple solution using the Visual Studio 2010 SharePoint Tools which will:</p>
<ol>
<li>deploy our CSS file in the <strong>Themable</strong> folder in the <em>/Layouts/1033/Styles</em></li>
<li>deploy a user control into the <em>ControlTemplates</em> folder which uses the <strong>CSSRegistration</strong> control to register our CSS</li>
<li>install a feature which inserts our user control onto our pages via the <strong>AdditionalPageHead</strong> delegate</li>
</ol>
<h4>The CSS</h4>
<p>Keeping it simple, all our CSS does is set the background color of the &lt;body&gt;. We&#8217;ll use #FFF (white) as our default background color and also decorate the rule with one of the SharePoint 2010 compile time directives to whatever we might set the &#8220;Light1&#8243; color value as through the Theme UI.</p>
<pre class="brush: plain;">
body {
/*[ReplaceColor(themeColor:&quot;Light1&quot;)]*/
background-color: #fff;
}
</pre>
<h4>The Delegate Control</h4>
<p>Again, nice and simple, we&#8217;re going to use the CSSRegistration control to register our branding CSS after corev4.css:</p>
<pre class="brush: plain;">
&lt;%@ Assembly Name=&quot;$SharePoint.Project.AssemblyFullName$&quot; %&gt;
&lt;%@ Register Tagprefix=&quot;SharePoint&quot; Namespace=&quot;Microsoft.SharePoint.WebControls&quot; Assembly=&quot;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %&gt;

&lt;sharepoint :CSSRegistration Name=&quot;&lt;% $SPUrl:~sitecollection/_layouts/1033/Styles/Themable/SingChan.SP2010.Branding/branding.css %&gt;&quot; After=&quot;corev4.css&quot; runat=&quot;server&quot; /&gt;
&lt;/sharepoint&gt;
</pre>
<h4>Element Manifest</h4>
<p>And finally we&#8217;ll define our element manifest for our delegate feature:</p>
<pre class="brush: plain;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;elements xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot;&gt;
    &lt;control Id=&quot;AdditionalPageHead&quot; Sequence=&quot;80&quot; ControlSrc=&quot;~/_ControlTemplates/SingChan.SP2010.Branding/CSSRegistrationControl.ascx&quot; /&gt;
&lt;/elements&gt;
</pre>
<p>You&#8217;ll most likely scope your delegate feature to either <em>Web</em> or <em>Site</em> for branding purposes. I tend to scope my feature at the site collection level to achieve a consistent brand across all the webs in the site collection. If there&#8217;s a requirement to have different branding for one or two specific sites, then we can always have a second feature which deploys those overrides at a web-level scope. If you have vastly different brands across webs in your site collection, then you may want to scope only at the web level so that your brands don&#8217;t conflict or end up with any style inheritance issues.</p>
<h3>That&#8217;s it!</h3>
<p>If all went well, we should see the link to our style sheet emitted after the link to corev4.css!<br />
<div id="attachment_210" class="wp-caption aligncenter" style="width: 160px"><a href="http://singchan.com/wordpress/wp-content/uploads/2010/02/brandingcss.png" rel="lightbox[181]" title="Branding CSS in HTML Source"><img src="http://singchan.com/wordpress/wp-content/uploads/2010/02/brandingcss-150x150.png" alt="Screen shot of HTML source of page containing a link to the branding CSS." title="Branding CSS in HTML Source" width="150" height="150" class="size-thumbnail wp-image-210" /></a><p class="wp-caption-text">Our branding CSS being emitted in HTML</p></div></link>
<p>If all is not well, here&#8217;s the ZIP file containing the branding VS2010 solution for reference:<br />
<a href='http://singchan.com/wordpress/wp-content/uploads/2010/02/SingChan.SP2010.Branding.zip' title="ZIP file containing the branding VS2010 solution">SingChan.SP2010.Branding.zip</a></p>
<h3>Previously&#8230;</h3>
<ul>
<li><a title="Branding SharePoint 2010 Collaboration Sites: Part 1" href="/2009/12/23/branding-sharepoint-2010-collaboration-sites-part-1-in-a-series/">You can find Part One here!</a></li>
<li><a title="Branding SharePoint 2010 Collaboration Sites: Part 2" href="/2009/12/29/branding-sharepoint-2010-collaboration-sites-part-2-in-a-series/">You can find Part Two here!</a></li>
</ul>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://singchan.com/2010/02/23/branding-sharepoint-2010-collaboration-sites-part-3-in-a-series/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Yaroslav on Customizing the SharePoint 2010 Ribbon</title>
		<link>http://singchan.com/2009/12/29/yaroslav-on-customizing-the-sharepoint-2010-ribbon/</link>
		<comments>http://singchan.com/2009/12/29/yaroslav-on-customizing-the-sharepoint-2010-ribbon/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 01:01:56 +0000</pubDate>
		<dc:creator>Buta</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[2010]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[ribbon]]></category>
		<category><![CDATA[ue]]></category>
		<category><![CDATA[user experience]]></category>
		<category><![CDATA[Yaroslav]]></category>

		<guid isPermaLink="false">http://singchan.com/?p=177</guid>
		<description><![CDATA[My buddy Yaroslav&#8217;s been blogging away about customizing the SharePoint 2010 ribbon, like the mad scientist that he is, over the past few weeks&#8230; Here&#8217;s what he&#8217;s got so far: Extending the SharePoint 2010 Ribbon Screen Cast: Starting with the SharePoint 2010 Ribbon More Ribbon locations to extend your SharePoint 2010 UI Creating a FlyoutAnchor [...]]]></description>
			<content:encoded><![CDATA[<p>My buddy Yaroslav&#8217;s been blogging away about customizing the SharePoint 2010 ribbon, like the mad scientist that he is, over the past few weeks&#8230;</p>
<p>Here&#8217;s what he&#8217;s got so far:</p>
<ul>
<li><a href="http://www.sharemuch.com/2009/12/16/extending-sharepoint-2010-ribbon/" target="_blank">Extending the SharePoint 2010 Ribbon</a></li>
<li><a href="http://www.sharemuch.com/2009/12/19/new-screencast-starting-with-sharepoint-2010-ribbon/" target="_blank">Screen Cast: Starting with the SharePoint 2010 Ribbon</a></li>
<li><a href="http://www.sharemuch.com/2009/12/17/more-ribbon-locations-to-extend-your-sharepoint-2010-ui/" target="_blank">More Ribbon locations to extend your SharePoint 2010 UI</a></li>
<li><a href="http://www.sharemuch.com/2009/12/23/creating-in-sharepoint-2010-ribbon/" target="_blank">Creating a FlyoutAnchor in the Ribbon</a></li>
<li><a href="http://www.sharemuch.com/2009/12/22/addingremoving-social-tagging-i-like-it-on-sharepoint-2010-ribbon/" target="_blank">Adding/Remvoing Social Tagging in the Ribbon</a></li>
<li><a href="http://www.sharemuch.com/2009/12/21/building-more-complex-sharepoint-2010-ribbon-structure/" target="_blank">Building a more complex SharePoint 2010 Ribbon Structure</a></li>
</ul>
<p>Go check it out!</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://singchan.com/2009/12/29/yaroslav-on-customizing-the-sharepoint-2010-ribbon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SPC09: Master Pages</title>
		<link>http://singchan.com/2009/10/21/spc09-master-pages/</link>
		<comments>http://singchan.com/2009/10/21/spc09-master-pages/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 23:58:13 +0000</pubDate>
		<dc:creator>Buta</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[2010]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[master page]]></category>
		<category><![CDATA[SPC09]]></category>

		<guid isPermaLink="false">http://singchan.com/?p=62</guid>
		<description><![CDATA[A quickie: no more application.master! In Microsoft SharePoint Foundation, application pages can now inherit a customized site master page through the DynamicMasterPageFile attribute. In addition, there are a few pages which have been designated as Safeguarded Application Pages. These are the application pages that have safeguards against a broken master page. If these pages encounter an [...]]]></description>
			<content:encoded><![CDATA[<p>A quickie: no more application.master!</p>
<p>In Microsoft SharePoint Foundation, application pages can now inherit a customized site master page through the <span><span>DynamicMasterPageFile</span></span> attribute.</p>
<p>In addition, there are a few pages which have been designated as Safeguarded Application Pages. These are the application pages that have safeguards against a broken master page. If these pages encounter an error when loading the dynamic master page, a safe master page in the _layouts folder is loaded instead.</p>
<ul>
<li>AccessDenied.aspx</li>
<li>MngSiteAdmin.aspx</li>
<li>People.aspx</li>
<li>RecycleBin.aspx</li>
<li>ReGhost.aspx</li>
<li>ReqAcc.aspx</li>
<li>Settings.aspx</li>
<li>UserDisp.aspx</li>
<li>ViewLsts.aspx</li>
</ul>
<p style="DISPLAY: block">Check out the <a title="MSDN documentation on SharePoint 2010 master pages." href="http://msdn.microsoft.com/en-us/library/ms443795(office.14).aspx" target="_blank">documentation on MSDN</a> regarding master pages in SharePoint 2010.</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://singchan.com/2009/10/21/spc09-master-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
