The first thing you need to do in order to be able to use the controls you've developed on a page is to add a Register directive:
<%@ Register TagPrefix=”MySite” Namespace=”Guestbook” Assembly=”Guestbook” %>
And now if you want to add the control GuestbookForm to the page you'd only need to add the following:
<MySite:GuestbookForm runat=”server” />
And if you wanted to change the text of i.e. the submit button you'd type this:
<MySite:GuestbookForm ButtonLabel=”Sign my guestbook” runat=”server” />
The GuestbookRepeater
control is a little more complex to add, because you need to define templates for it. Here is one example of adding it to a page:
<MySite:GuestbookRepeater runat="server">
<HeaderTemplate>
<table cellpadding="2" bgcolor="#666666" cellspacing="1" border="0" width="400">
</HeaderTemplate>
<ItemTemplate>
<tr bgcolor="#eeeeee">
<td>
<b><%# DataBinder.Eval(Container.DataItem, "name") %></b><br/>
<%# DataBinder.Eval(Container.DataItem, "email") %><br/><br/>
<%# ((string) DataBinder.Eval(Container.DataItem, "message")).Replace("\n", "<br/>") %><br/><br/>
<i>Rating: <%# DataBinder.Eval(Container.DataItem, "rating") %></i>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr bgcolor="#dddddd">
<td>
<b><%# DataBinder.Eval(Container.DataItem, "name") %></b><br/>
<%# DataBinder.Eval(Container.DataItem, "email") %><br/><br/>
<%# ((string) DataBinder.Eval(Container.DataItem, "message")).Replace("\n", "<br/>") %><br/><br/>
<i>Rating: <%# DataBinder.Eval(Container.DataItem, "rating") %></i>
</td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</MySite:GuestbookRepeater>
That's it, hope you've enjoyed reading this!
Comments