<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>John W Powell : MOSS</title><link>http://blogs.msdn.com/johnwpowell/archive/tags/MOSS/default.aspx</link><description>Tags: MOSS</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Subscribe to SharePoint Web Parts using Internet Explorer 8 Web Slices</title><link>http://blogs.msdn.com/johnwpowell/archive/2009/02/01/subscribe-to-sharepoint-web-parts-using-internet-explorer-8-web-slices.aspx</link><pubDate>Mon, 02 Feb 2009 00:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9388724</guid><dc:creator>johnwpowell</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/johnwpowell/comments/9388724.aspx</comments><wfw:commentRss>http://blogs.msdn.com/johnwpowell/commentrss.aspx?PostID=9388724</wfw:commentRss><description>&lt;P&gt;One of the new features of Internet Explorer 8 is &lt;EM&gt;Web Slices.&amp;nbsp; &lt;/EM&gt;This feature enables you to subscribe to a &lt;EM&gt;section&lt;/EM&gt; of a web page and notifies you when the content changes.&amp;nbsp; By design, SharePoint Web Parts are a natural fit for this feature, and in this article I’ll show you how to build a Web Part that does just that.&amp;nbsp; I’ll also show you how easy it is to develop a web part using the CTP release of Visual Studio 2008 Extensions for Windows SharePoint Services (VSSWse) 1.3.&lt;/P&gt;
&lt;H3&gt;About Web Slices&lt;/H3&gt;
&lt;P&gt;Web Slices enable you to have a very narrow control over the content you subscribe to.&amp;nbsp; When you browse a page that has Web Slice sections, they “light up” when you hover over them:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_2.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb.png" width=344 height=68 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;In addition, the new Web Slice icon on the toolbar lights up, and the menu is populated with all the slices on the page:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_4.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_4.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_1.png" width=198 height=59 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_1.png"&gt;&lt;/A&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;When you subscribe to a slice, the web page section is added to the toolbar and is periodically refreshed.&amp;nbsp; The refresh interval is completely customizable and can also be refreshed manually:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_6.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_6.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_2.png" width=426 height=297 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_2.png"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;Defining a Web Slice Section&lt;/H3&gt;
&lt;P&gt;Web Slices are defined with HTML tags that have certain CSS classes.&amp;nbsp; You can read the &lt;A href="http://msdn.microsoft.com/en-us/library/cc304073%28VS.85%29.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/cc304073%28VS.85%29.aspx"&gt;full specification&lt;/A&gt;, but here’s all you need to know to build your first Web Slice:&lt;/P&gt;
&lt;P&gt;To define a Web Slice section, use the &lt;EM&gt;hslice&lt;/EM&gt; class name:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;lt;div class="hslice" id="1"&amp;gt;…&amp;lt;/div&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;To define the slice title, use the &lt;EM&gt;entry-title&lt;/EM&gt; class name:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;lt;p class="entry-title"&amp;gt;Game System - $66.00&amp;lt;/p&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;To define the slice content, use the &lt;EM&gt;entry-content&lt;/EM&gt; class name:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;lt;div class="entry-content"&amp;gt;This auction closes in 4 hours.&amp;lt;/div&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The end result looks like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;&amp;lt;div class="hslice" id="1"&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;p class="entry-title"&amp;gt;Game System - $66.00&amp;lt;/p&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="entry-content"&amp;gt;This auction closes in 4 hours.&amp;lt;/div&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;lt;/div&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;H3&gt;Build a SharePoint Web Part&lt;/H3&gt;
&lt;P&gt;For this example, I’m using VSSWSE 1.3 which you can read about &lt;A href="http://blogs.msdn.com/sharepoint/archive/2009/01/12/announcing-community-technology-preview-of-visual-studio-2008-extensions-for-sharepoint-v1-3.aspx" target=_blank mce_href="http://blogs.msdn.com/sharepoint/archive/2009/01/12/announcing-community-technology-preview-of-visual-studio-2008-extensions-for-sharepoint-v1-3.aspx"&gt;here&lt;/A&gt;.&amp;nbsp; I would recommend it not only because it’s easy to use, but also because it is sure to become the de-facto standard.&amp;nbsp; To get started, create a new Web Part project:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_8.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_8.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_3.png" width=616 height=442 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_3.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Choose if you want to deploy to the GAC or bin directory.&amp;nbsp; We’ll use GAC for this example:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_10.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_10.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_4.png" width=362 height=215 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_4.png"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A solution is created with a default web part named WebPart1.&amp;nbsp; Rather than renaming it, delete the WebPart1 folder and add a new Web Part to the project with a more descriptive name:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_12.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_12.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_5.png" width=616 height=373 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_5.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Next, configure the url of your SharePoint site you want to use to test the Web Part.&amp;nbsp; On the Debug settings, set the start url:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_20.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_20.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_9.png" width=615 height=113 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_9.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;In the Web Part, override the CreateChildControls method:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_16.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_16.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_7.png" width=616 height=363 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_7.png"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code generates the needed HTML and is pretty self-explanatory.&amp;nbsp; I chose to hide the Web Slice entry-title as it would be redundant beneath the Web Part title.&amp;nbsp; To test the code, right-click the solution or project and select Deploy.&amp;nbsp; This will package the Web Part as a feature and deploy and activate it on the site:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_22.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_22.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_10.png" width=392 height=169 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_10.png"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, add the Web Part to a page in the site and test it.&lt;/P&gt;
&lt;H3&gt;How I Wished It Worked&lt;/H3&gt;
&lt;P&gt;Web Slices are powerful, but I don’t really want to develop a bunch of new Web Parts to use that feature.&amp;nbsp; I wish every Web Part were capable of wrapping its content in a Web Slice div tag.&amp;nbsp; I’m sure there is a way to inject this functionality (and there might even be a supported method), but I wish it were built in to the Web Part framework.&amp;nbsp; Every Web Part could then have a Web Slice category with relevant settings:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_18.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_18.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_8.png" width=237 height=219 mce_src="http://blogs.msdn.com/blogfiles/johnwpowell/WindowsLiveWriter/cb2a34ee5175_A8A8/image_thumb_8.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Wouldn’t that be powerful?&lt;/P&gt;
&lt;H3&gt;Summary&lt;/H3&gt;
&lt;P&gt;In this article, I demonstrated how to build a Web Part that users can subscribe to using Web Slices.&amp;nbsp; I also showed you how easy it is to build a Web Part using the CTP release of Visual Studio 2008 Extensions for Windows SharePoint Services version 1.3.&amp;nbsp; Happy slicing!&lt;/P&gt;
&lt;H3&gt;References and Additional Reading&lt;/H3&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.microsoft.com/windows/internet-explorer/download-ie.aspx" target=_blank&gt;Internet Explorer 8 Download&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/cc196992(VS.85).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/cc196992(VS.85).aspx"&gt;Subscribing to Content with Web Slices&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/cc304073%28VS.85%29.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/cc304073%28VS.85%29.aspx"&gt;Web Slice Format Specification&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=4A7F2178-DB7E-4325-98B5-15FA725708E2&amp;amp;displaylang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?familyid=4A7F2178-DB7E-4325-98B5-15FA725708E2&amp;amp;displaylang=en"&gt;Web Slice Icon and Guidelines&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://www.microsoft.com/windows/internet-explorer/beta/videos.aspx?vindex=3" target=_blank mce_href="http://www.microsoft.com/windows/internet-explorer/beta/videos.aspx?vindex=3"&gt;Internet Explorer 8 Videos : Web Slices&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9388724" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/.Net/default.aspx">.Net</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/WSS/default.aspx">WSS</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/WSS3/default.aspx">WSS3</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/Windows+SharePoint+Services/default.aspx">Windows SharePoint Services</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/MOSS/default.aspx">MOSS</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/SharePoint+2007/default.aspx">SharePoint 2007</category><category domain="http://blogs.msdn.com/johnwpowell/archive/tags/SharePoint/default.aspx">SharePoint</category></item></channel></rss>