Load event in calendar selection event (C#) : Calendar « Asp Control « ASP.Net






Load event in calendar selection event (C#)

<%@ Page language="c#" src="Appointment.aspx.cs" AutoEventWireup="false" Inherits="Appointment" %>
<HTML>
  <body>
    <form id="Form1" method="post" runat="server">
      <asp:Calendar id="Calendar1" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 16px" runat="server" SelectionMode="DayWeekMonth" BorderWidth="1px" BackColor="#FFFFCC" Width="220px" DayNameFormat="FirstLetter" ForeColor="#663399" Height="200px" Font-Size="8pt" Font-Names="Verdana" BorderColor="#FFCC66" ShowGridLines="True">
        <TodayDayStyle ForeColor="White" BackColor="#FFCC66"></TodayDayStyle>
        <SelectorStyle BackColor="#FFCC66"></SelectorStyle>
        <NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC"></NextPrevStyle>
        <DayHeaderStyle Height="1px" BackColor="#FFCC66"></DayHeaderStyle>
        <SelectedDayStyle Font-Bold="True" BackColor="#CCCCFF"></SelectedDayStyle>
        <TitleStyle Font-Size="9pt" Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></TitleStyle>
        <OtherMonthDayStyle ForeColor="#CC9966"></OtherMonthDayStyle>
      </asp:Calendar>
      <asp:ListBox id="lstTimes" style="Z-INDEX: 102; LEFT: 24px; POSITION: absolute; TOP: 248px" runat="server" Width="216px" Height="160px"></asp:ListBox>
    </form>
  </body>
</HTML>


<%-- Appointment.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

  public class Appointment : System.Web.UI.Page
  {
    protected System.Web.UI.WebControls.Calendar Calendar1;
    protected System.Web.UI.WebControls.ListBox lstTimes;
  
    private void Page_Load(object sender, System.EventArgs e)
    {
    }

    #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
      //
      // CODEGEN: This call is required by the ASP.NET Web Form Designer.
      //
      InitializeComponent();
      base.OnInit(e);
    }
    
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {    
      this.Calendar1.DayRender += new System.Web.UI.WebControls.DayRenderEventHandler(this.Calendar1_DayRender);
      this.Calendar1.SelectionChanged += new System.EventHandler(this.Calendar1_SelectionChanged);
      this.Load += new System.EventHandler(this.Page_Load);

    }
    #endregion

    private void Calendar1_DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
    {
      // Check for May 5 in any year, and format it.
      if (e.Day.Date.Day == 5 && e.Day.Date.Month == 5)
      {
        e.Cell.BackColor = System.Drawing.Color.Yellow;

        // Add some static text to the cell.
        Label lbl = new Label();
        lbl.Text = "<br>My Birthday!";
        e.Cell.Controls.Add(lbl);
      }

    }

    private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
    {
      lstTimes.Items.Clear();
      
      switch (Calendar1.SelectedDate.DayOfWeek)
      {
        case DayOfWeek.Monday:
          // Apply special Monday schedule.
          lstTimes.Items.Add("10:00 >> working");
          lstTimes.Items.Add("10:30 >> Meeting");
          lstTimes.Items.Add("11:00 >> Coding");
          break;
        default:
          lstTimes.Items.Add("10:00 >> Coding");
          lstTimes.Items.Add("10:30");
          lstTimes.Items.Add("11:00");
          lstTimes.Items.Add("11:30");
          lstTimes.Items.Add("12:00 >> lauching");
          lstTimes.Items.Add("12:30");
          break;
      }

    }
  }


--%>
           
       








Related examples in the same category

1.Change Calendar selection based on data from the database (VB.net)
2.Calendar selected value changed event (VB.net)
3.Assign today's date to asp calendar (VB.net)
4.Set asp calendar border (VB.net)
5.Calendar Control: day name format, first day of week (VB.net)
6.Calendar Control: nextprevformat (VB.net)
7.Calendar Control: titleformat (VB.net)
8.Controlling the Appearance of Individual Cells of Dates (VB.net)
9.Calendar control: on day render (VB.net)
10.Formatting Date Sections in a Calendar Control (VB.net)
11.Date Selection event in a Calendar Control (VB.net)
12.Formatting the Header Styles in a Calendar Control (VB.net)
13.On visible month changed event for a calendar control (VB.net)
14.Setting Custom Previous and Next Month Text in the Calendar Control (VB.net)
15.Reading Selected Dates in a Date Range through the Calendar Control (VB.net)
16.Allowing the Selection of Multiple Dates in a Calendar Control (VB.net)
17.Displaying a Date in the Calendar Control (VB.net)
18.Displaying a Selected Range of Dates in the Calendar Control (VB.net)
19.Basic Calendar Control: show grid lines, show day header (VB.net)
20.On Date and Month Selection Changed (VB.net)
21.Select a week (VB.net)
22.Convert selected date from asp:Calendar to long string (VB.net)
23.Selected value change envent for asp:Calendar (VB.net)
24.Get selected date from asp:Calendar (VB.net)
25.Calendar with TodayDayStyle, SelectorStyle, NextPrevStyle, and SelectedDayStyle (C#)
26.Calendar control in code behind (C#)
27.Define and use calendar in code behind (C#)
28.Embed Javascript to C# code to create a popup window
29.Popup calendar
30.Calendar events: render and change events
31.Visible month changed event
32.Day renderer
33.Calendar selection changed event
34.Calendar selection mode: DayWeekMonth
35.Calendar selection mode: Day
36.Calendar selection mode: DayWeek
37.Add control to Calendar cell
38.Set TodayDayStyle: background color and foreground color
39.Set DayStyle, NextPrevStyle, DayHeaderStyle, TitleStyle, WeekendDayStyle
40.Change size of Calendar
41.Check the range of Calendar controls