Saturday, January 26, 2008

How to use Footnote to annotate a Web Page

JHA Fundperformance uses Genearic List to render foonotes for product title and each fund. In general render footnotes requires insert DataBinding Expression at the right location and keep counter updated.
Here are the code for simplest Footnoting a Web Page:

<%@ Page Language="C#" ... Inherits="TestFootNotes._Default" %>

Test Footnoting a web page<br />
Web Pages are structure less<%# RenderFootNoteNumber("struct") %> writting of information. Therefore, annotate certain part of it requires putting a structure at certain location<%# RenderFootNoteNumber("location") %>.
<hr />
Footnotes: <br />
<asp:Repeater ID="Repeater1" runat="server" DataSource="<%# _FootnoteList %>">
<ItemTemplate>
[<%# Eval("key") %>]. <%# Eval("value") %><br />
</ItemTemplate>
</asp:Repeater>



public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataBind();
}
public Dictionary _FootnoteList = new Dictionary();
public string RenderFootNoteNumber(string AnnotationID)
{
int i=_FootnoteList.Count;
_FootnoteList.Add(i + 1, "Footnote Content for Annotation of " + AnnotationID );
return "<sup>["+_FootnoteList.Count.ToString()+"]</sup>";
}
}


The key is to have _FootNoteList as a holder of footnote counter and content as we going through the Web Page.

No comments: