<%@ Page Language="C#" Inherits="HawhawPage" %>
<%@ Register Assembly="Hawhaw" Namespace="Hawhaw" TagPrefix="Haw" %>

<!--
        HAWHAW example how to make tables
        Norbert Huffschmid
        29.3.2009
-->

<script runat="server">

    protected void Page_Load()
    {
        string who = Page.Request.QueryString["who"];

        if (who == null)
        {
            // first pass: add content to calendar
            
            string[] names = new string[] {
                "Peter", "Mary", "John", "Jane", "Norbert", "Sue", "Mike",
                "Jenny", "Lloyd", "Tamara", "Ben", "Betty", "Tom", "Clara",
                "Bob", "Ellen", "Rick", "Nicole", "Jack", "Liz", "Edward",
                "Monica", "Bill", "Maria", "Pedro", "Nelly", "Ted", "Kitty",
                "Andy", "Sabrina", "George", "", "", "", "" };
            
            for (int week=0; week < 5; week++) // do for each week ...
            {
                Hawhaw.TableRow tableRow = new Hawhaw.TableRow();
                
                for (int i=0; i<7; i++) // do for each day ...
                {
                    Hawhaw.TableCell tableCell = new Hawhaw.TableCell();
                    
                    int day = week * 7 + i + 1;
                    
                    if (day <= 31)
                    {
                        // create one link per day
                        Hawhaw.Link link = new Hawhaw.Link();
                        link.Text = day.ToString();
                        link.Title = names[day-1];
                        link.NavigateUrl = this.Request.Url.AbsolutePath + "?who=" + names[day-1];
                        tableCell.Controls.Add(link);
                    }
                    
                    tableRow.Controls.Add(tableCell);
                }
                
                // add row to table
                BirthdayTable.Controls.Add(tableRow);

                Info.Visible = false;
            }
        }
        else
        {
            // second pass: show info
            
            BirthdayTable.Visible = false;
            Info.Text ="Today is " + who + "'s birthday!";
        }
    }
    
>

<Haw:Deck runat="server" ID="CalendarDeck" Title="October 2009" Simulator="Skin" HorizontalAlign="Center">

    <Haw:Label runat="server" ID="Info" Text="" Bold="True" />
    <Haw:Table runat="server" ID="BirthdayTable">
        <Haw:TableRow runat="server">
            <Haw:TableCell runat="server">
                <Haw:Label runat="server" Text="M" Bold="True" Small="True" />
            </Haw:TableCell>
            <Haw:TableCell runat="server">
                <Haw:Label runat="server" Text="T" Bold="True" Small="True" />
            </Haw:TableCell>
            <Haw:TableCell runat="server">
                <Haw:Label runat="server" Text="W" Bold="True" Small="True" />
            </Haw:TableCell>
            <Haw:TableCell runat="server">
                <Haw:Label runat="server" Text="T" Bold="True" Small="True" />
            </Haw:TableCell>
            <Haw:TableCell runat="server">
                <Haw:Label runat="server" Text="F" Bold="True" Small="True" />
            </Haw:TableCell>
            <Haw:TableCell runat="server">
                <Haw:Label runat="server" Text="S" Bold="True" Small="True" />
            </Haw:TableCell>
            <Haw:TableCell runat="server">
                <Haw:Label runat="server" Text="S" Bold="True" Small="True" />
            </Haw:TableCell>
        </Haw:TableRow>
        <!-- the rest is filled programmatically on Page_Load (see above) -->
    </Haw:Table>    
</Haw:Deck>