The recent Internet Explorer 8 Beta for Developers has brought us Activities and Web Slices. Web Slices already have a Firefox implementation. I'm hoping Activities will catch on and we'll see a Mozilla-based implementation soon (if there isn't one already) - the ability to load your own page within another is pretty cool.

The example we were shown at Remix was an Activity created to display car search results from any other page. E.g. I'm taking my regular look at the DBS and for a laugh I want to see how much they are. Instead of selecting the car name and pasting it into the browser search bar and looking through the results I simply select the car name, right-click and mouse-over the "Search in CarWebsite.." Activity and I see the search results in a mini-browser window!

For the moment though they're limited to IE8 - for now I'm gonna focus on web slices.

Web slices allow users to subscribe to specific content within a page, rather than the whole page (or site) like RSS. When clients detect a change in the content they can notify the user and display the updated slice in a small view pane in the browser.

I've just created a small ASP.NET Web Slices project over at Codeplex that contains, among other things, a WebSlice ASP.NET control. Using this control it's a simple job of creating a new web application with web slices and also easy to add web slices to an existing application. The control works much like an <asp:Panel/> control in that it's a container for other controls. Any child controls of this WebSlice will be the web slice content. The Title, TimeToLive and EndTime control properties can be used to further customise the web slices.

<body>
     <form id="form1" runat="server">
         <div>
             <slices:WebSlice Title="Web Slice Title" runat="server" ID="slice" EndTime="06/06/2008" TimeToLive="1:00:00">
                 <p>Lorem...</p>
                 <p>Expires on <asp:PlaceHolder ID="endTime" runat="server" /> 
                 (Updates every <asp:PlaceHolder runat="server" ID="timeToLive" /> minutes)</p>
             </slices:WebSlice>
         </div>
     </form>
</body>

The output is simple XHTML with the required web slice CSS classes.

<div id="Div1" class="hslice">
     <h4 class="entry-title">Web Slice Title</h4>
     <div class="entry-content">
         <p>Lorem...</p>
         <p>Expires on <abbr class="end-time" title="2008-06-06T00:00:00">Fri, 06 Jun 2008 00:00:00 GMT</abbr> (Updates every <span class="ttl">60</span> minutes)</p>
     </div>
</div>

There isn't any magic going on here. The control is simply taking care of markup and semantics instead of copy-paste work. When IE 8 parses the above XHTML it will know that this is a web slice and will allow the user to subscribe to it:

WebSliceSubscribe

There are also some extension methods available on Page objects when the WebSlices namespaces is being used. These methods allow the developer to customise the discovery of web slices.

At the moment there are two methods. The first is named SetDefaultWebSlice<TWebSlice>(TWebSlice slice) and provides a means to set the default web slice. You'd pretty much only do this when there are several slices on the page and the one you want to be default appears after other slices (the first slice to be parsed is the default).

using WebSlices;
  
namespace SampleApplication
{
     public partial class _Default : System.Web.UI.Page
     {
         protected void Page_Load(object sender, EventArgs e)
         {
             this.SetDefaultWebSlice<WebSlice>(this.slice);
         }
     }
 }

The second method is named SetWebSliceDiscoveryMode(WebSliceDiscoveryMode mode) and allows developers to turn off web slice discovery for the current page.

using WebSlices;
  
namespace SampleApplication
{
     public partial class _Default : System.Web.UI.Page
     {
         protected void Page_Load(object sender, EventArgs e)
         {
             this.SetWebSliceDiscoveryMode(WebSliceDiscoveryMode.Off);
         }
     }
}

ASP.NET Web Slices using web slices easy and allows developers with little or no inclination to start writing (read: copy and pasting) XHTML around to use web slices in their application. It's certainly not complete and there is more to do - better customisation and a JavaScript library to be able to add and update the slices in the browser are up next.

Perhaps web slices will never take off. If they don't I'm sure there will be more features in the future based off the idea. I certainly see them being useful for small web sites that have no CMS to generate RSS feeds automatically. With web slices the HTML and browser do this work for them - all they need do is modify their markup and users can be notified of changes. Ebay have also put the feature to good use in their IE8 specific implementation. I'm looking forward to seeing how other sites implement the new features.

Last edited Oct 19, 2008 at 7:15 AM by davescriven, version 1

Comments

No comments yet.