How to add a Webslice

How to add a Webslice - Microsoft technology to enable subscribing to content

It is very nice and user-friendly to have Webslices on your website. It improves the user experience by allowing visitors to be up to date with the latest content that you provide, assuming that it is fitted to this presentation style. Since my BNR exchange rates page was this kind, I pursued in adding a Webslice especially for it.

Adding a webslice to your website is simple. After you read the main specifications or my previous article, you’ll understand the concept behind: first you signal to the browser that you have a special part of your website by setting to a container element the class “hslice”:

<div id="BNRExchange" class="hslice">
  <div style="display: none" class="entry-title">
    <img id="image" alt="Radu Poenaru's weblog gives you BNR Exchange rates" src="" width="128" height="128" />
       Cursul oficial BNR 
    <a style="display: none" href="" rel="entry-content">
    <a style="display: none" href="" rel="Bookmark" target="_blank">
    <span style="display: none" class="ttl">5</span>
  <div id="updateTrigger" class="entry-content" runat="server" />
........ your content that you want surrounded by the green webslice part ..............

The id of the container must be the same for all the container who contain the same information – as in my case, the graph of the exchange rates must have the same Id on every page.

Very important to add is the link to the actual page who will generate the content, in my case a php file. Thus, you’re not obliged to use Microsoft’s languages, like C# or VB, but you can use anything – from plain HTML, JavaScript, PHP, Ruby on Rails – just to mention few.

Then you have to specific the refresh period of the page by using the ttl class, set at 5 minutes intervals in my case.

Another very interesting thing on this technology is that you can surround content with it, making clear to the user what he will use if he wants that Webslice’s content.