Calender Control - Asp.Net

 




.aspx.cs file 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace calender
public partial class WebForm1: System.Web.UI.Page
f
protected void Page_Load(object sender, EventArgs e)
(
}
Calendar1.SelectionMode = (CalendarSelectionMode)ddlmodes.SelectedIndex;
if (Calendar1.SelectionMode == CalendarSelectionMode.None)
Calendar1 SelectedDates Clear();
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
switch (Calendar1.SelectedDates.Count)
case(0):
lable1.Text = "no detail are curently selected";
break;
case(1):
lable1.Text = "date is: " + Calendar1 SelectedDate.ToShortDateString().
break;
case(7):
lable1.Text = "selected is a week beginning" + Calendar1.SelectedDate.ToShortDateString(); break;
default:
lable1.Text = "selected is a month beginning" + Calendar1.SelectedDate.ToShortDateString(); break;


.aspx file


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="calender.WebForm1"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body style="height: 500px; width: 983px">
<form id="form1" runat="server">
<div style="height: 461px">
<table align="center" border="2" style="height: 363px; width: 275px">
<tr>
<td class="style1">
selection mode:
<asp:DropDownList ID="ddlmodes" runat="server" AutoPostBack="true">
<asp:ListItem Value="none">none</asp:ListItem>
<asp:ListItem Value="day" Selected="True">day</asp:ListItem>
<asp:ListItem Value="day week">day week</asp:ListItem>
<asp:ListItem Value="day week month">day week month</asp:ListItem> </asp:DropDownList>
</td>
</tr>
<tr>
<td class="style2">
<asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged "Calendar1_SelectionChanged" SelectWeekText="week"
Select MonthText="month" BackColor="#ffcc99"
BorderColor="#ffccff" BorderStyle="Groove" DayHeaderStyle-BackColor="#ff66cc" NextPrevFormat="ShortMonth"
DayHeaderStyle-ForeColor="#336600" Other MonthDayStyle-BackColor="#ff0066" NextPrevStyle-
BorderStyle="Ridge"
forecolor="#cc9900"
OtherMonthDayStyle-forecolor="#660033 SelectedDayStyle-BackColor="#66ffff" SelectedDayStyle-
Font-Bold="true"> <DayHeaderStyle BackColor="#ffffcc" BorderColor="#ffff66"/> </asp:Calendar>
</td> </tr>
<tr>
<td class="style3">
<asp:Label ID="lable1" runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

Post a Comment

0 Comments