MSDN Magazine - March 2009 - (Page 49) As I mentioned earlier, Web Slices are predefined by the developer. So how do you define those parts? First of all, you need to mark an HTML div element as a Web Slice container using the hslice class name. The hslice element will contain all the rest of the definitions you need for your Web Slice. Here’s an empty Web Slice definition: Each Web Slice must have a unique ID, as this is how Internet Explorer distinguishes one from the other on a page. If the ID of a Web Slice changes after users subscribe to it, Internet Explorer will not be able to find it anymore and will not be able update the content on the favorites bar. Each Web Slice should contain an element to identify the title of the slice; the title is identified by the CSS class entry-title. This content will be shown on the favorites bar and the feed discovery command bar menu. The entry-title text can be changed if you like when the Web Slice updates itself. To finish creating my first Web Slice I have to add just one more element: the entry-content. I have the Web Slice and the title defined but I don’t have any content to show to the user. So let’s define the Web Slice content by applying the CSS class entry-content on the content that should be displayed to the user: Brand New Product! This is the product definition. Figure 1 Discovering a Web Slice by Hovering Figure 3 shows my Web Slice definition. My Web Slice, called ProductID, has a title and content. You can add further richness to the Web Slice user experience with visual elements and inline (or global) CSS styles. The only limitation is that no scripting or ActiveX controls (including Silverlight) are allowed. If you need ActiveX ,you will need to use an alternative display source. An alternative display source can be defined on the entry-content container element of the Web Slice. As shown here, you don’t need to put the content inside the entrycontent element. You are simply redirecting the Web Slice and telling the browser that the content will come from another URL: Brand New Product Figure 2 Finding the Latest Bid on an Auction in a Web Slice alternative_display.aspx page you are allowed to use ActiveX controls. Expiration and Update Frequency Sometimes you will need Web Slices to expire in a timely manner Figure 3 A Simple Web Slice even if the user is offline and the Web Slice can’t get updated. This is especially true for sites such as online auctions or online sales March 2009 49 This way you will be able to track how many times each Web Slice is updated and how many users are following which slices by simply tracking the display source pages. In addition, in the target msdnmagazine.com http://www.msdnmagazine.com
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.