Calendar demo

Source of: Resources.aspx
<script runat="server">

    //
    // Updates a name of the selected resource with new one.
    //
    protected void UpdateButton_Click(object sender, EventArgs e) {
        if (ResourceList.SelectedItem!=null)
            ResourceList.SelectedItem.Text = ResourceTextBox.Text;
    }

    //
    // Adds a new resource just after selected resource on the list.
    //
    protected void AddButton_Click(object sender, EventArgs e) {
        ResourceList.Items.Insert(
			ResourceList.SelectedIndex+1,
			ResourceTextBox.Text);
        ResourceList.SelectedIndex = ResourceList.SelectedIndex+1;
    }

    //
    // Removes selected resource from the list box.
    //
    protected void DeleteResource_Click(object sender, EventArgs e) {
        if (ResourceList.SelectedIndex>=0)
            ResourceList.Items.RemoveAt(ResourceList.SelectedIndex);
    }

    //
    // Copies list of resources from the list box into the calendar Resources collection.
    //
    protected void Calendar_PreRender(object sender, EventArgs e) {
        Calendar.Resources.Clear();
        foreach (ListItem it in ResourceList.Items) {
            Resource res = new Resource();
            res.Text = it.Text;
            Calendar.Resources.Add(res);
        }
    }
     
</script>
<table width="100%">
    <tr>
        <td style="width:50%">
            <goc:DailyCalendar ID="Calendar" runat="server" BorderColor="SaddleBrown" Font-Names="Times New Roman"
                Font-Size="Medium" Height="348px" Width="100%" FreeHourColor="PaleGoldenrod" LineColor="Peru" WorkHourColor="PaleGoldenrod" OnPreRender="Calendar_PreRender">
                <DateBarStyle Font-Bold="True" Font-Italic="False" HorizontalAlign="Center" BackColor="Chocolate" ForeColor="OldLace" />
                <AllDayBarStyle BackColor="Chocolate" />
                <DefaultAllDayAppointmentStyle BackColor="White" />
                <ResourceBarStyle Font-Bold="True" Font-Italic="True" HorizontalAlign="Center" BackColor="SaddleBrown" ForeColor="OldLace" />
                <HoursBarStyle BackColor="BurlyWood" Font-Names="Arial" Font-Size="Small" ForeColor="Sienna" />
                <PreviousDayButton ButtonType="Link">
                    <Style Font-Underline="False" ForeColor="OldLace" />
                </PreviousDayButton>
                <NextDayButton ButtonType="Link">
                    <Style Font-Underline="False" ForeColor="OldLace" />
                </NextDayButton>
                <DefaultAppointmentStyle BackColor="White" />
            </goc:DailyCalendar>
        </td>
        <td valign="top">
            Edit list of resources below to change columns in the calendar.<br />
            <br />
            Resources list:<br />
            <asp:ListBox ID="ResourceList" runat="server" Height="110px" Width="401px">
                <asp:ListItem>Resource one</asp:ListItem>
                <asp:ListItem>Resource two</asp:ListItem>
            </asp:ListBox><br />
            <br />
            Resource name:<br />
            <asp:TextBox ID="ResourceTextBox" runat="server" Width="394px"></asp:TextBox><br />
            <br />
            <asp:Button ID="UpdateButton" runat="server" Text="Update resource" CommandName="upd" OnClick="UpdateButton_Click" />&nbsp;
            <asp:Button ID="AddButton" runat="server" Text="Add resource" CommandName="add" OnClick="AddButton_Click" />&nbsp;
            <asp:Button ID="DeleteResource" runat="server" Text="Delete resource" CommandName="del" OnClick="DeleteResource_Click" /></td>
    </tr>
</table>

(C) ComponentGo! 2010 | Home | Site map | Partners | Links | Forum | info@componentgo.com