Here's the source of a page demonstrating the use of the NinetyNineBottles.Binge class in an ASP.NET page.
<%@ Register TagPrefix="parkscom" TagName="Menu" Src="/bin/Menu.ascx" %>
<%@ Register TagPrefix="parkscom" TagName="Script" Src="/bin/Script.ascx" %>
<%@ Page language="c#" src="/dotnet/NinetyNineBottles.cs"%>
<%@ Import namespace="NinetyNineBottles" %>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>99 Bottles of Beer</title>
<parkscom:Script runat="server" />
<!--#include virtual="/includes/styles.inc"-->
<script language="C#" runat="server">// <!--
const int bottleCount = 99;
public void WriteLine(string format, params object[] arg)
{
string outString = format.Replace("\n", "<br />");
Response.Write(String.Format(outString, arg) + "<br />");
}
public int SevenEleven()
{
WriteLine("Go to the store, get some more...");
return bottleCount;
}
// -->
</script>
</head>
<body>
<parkscom:Menu runat="server" />
<div class="main">
<h1>99 Bottles of Beer, the Song</h1>
<p>
Here it the 99 Bottles of Beer song as generated by
<a href="ninetyninebottles.aspx">a C# class that I wrote</a>
to generate the lyrics. You may
<a href="/dotnet/99bottlesSrc.aspx">view the source of this page</a>
to see how it uses the class to generate the output.
</p>
</div>
<div class="section">
<h2>99 Bottles of Beer</h2>
<div class="sectioncontent"><p><%
Binge binge = new Binge("beer", bottleCount, new Writer(WriteLine));
binge.OutOfBottles += new MakeRun(SevenEleven);
binge.Start();
int i = 0;
%></p></div>
</div>
<!--#include virtual="/includes/info.inc"-->
</body>
</html>
Comments