Thursday, May 01, 2008

When you add a WMS:Lister control to the actual article template (e.g. a "News Detail" template) the lister may break.  This is because the "ItemIdentifier" attribute is repeated twice on the page!

For example: Say you have an article page that uses <!-- item --> to identify the region of the page the PatternFile refers to, if you then add an actual lister control to the page you end up with two <!-- item --> comments (see below). Once in teh new lister and once for the article!

  <ez:Lister ID="scrollingNews" runat="server" PageSize="4" 
     SortBy="Date" SortDirection="Desc" PatternFile="~/NewsPattern.txt" ItemFileExtension="*.aspx"
     ItemDirectory="~/News" PagerStyle="None" ItemIdentifier="<!-- item -->"
     CreateCacheIndex="true" FilterKey="Section" FilterValue="">
     <HeaderTemplate><span id="news_listing"></HeaderTemplate>
     <ItemTemplate>
       <a href="<%# ((ListerItem)Container.DataItem).Link %>">
        <wg:PlainText MaxLength="80" Text='<%# ((ListerItem)Container.DataItem).GetValue("text") %>' runat="server" />...
       </a>
     </ItemTemplate>
    <FooterTemplate></span></FooterTemplate>
  </ez:Lister>

The fix is simply to leave the ItemIdentifier attribute out of any Lister control.  The default value is <!-- item -->, so you only need the attribute if you need a different value.

:)

code | WMS