Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta charset="utf-8" /> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#3366CC" BorderWidth="1px" CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" ForeColor="#003399" Height="200px" Width="220px"> <DayHeaderStyle BackColor="#99CCCC" ForeColor="#336666" Height="1px"></DayHeaderStyle> <NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF"></NextPrevStyle> <OtherMonthDayStyle ForeColor="#999999"></OtherMonthDayStyle> <SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99"></SelectedDayStyle> <SelectorStyle BackColor="#99CCCC" ForeColor="#336666"></SelectorStyle> <TitleStyle BackColor="#003399" BorderColor="#3366CC" BorderWidth="1px" Font-Bold="True" Font-Size="10pt" ForeColor="#CCCCFF" Height="25px"></TitleStyle> <TodayDayStyle BackColor="#99CCCC" ForeColor="White"></TodayDayStyle> <WeekendDayStyle BackColor="#CCCCFF"></WeekendDayStyle> </asp:Calendar> <br /> <br /> <asp:Button ID="Button1" runat="server" Text="OK" OnClick="Button1_Click" /> <asp:Button ID="Button2" runat="server" Text="Clear" OnClick="Button2_Click" /> <br /> <br /> <asp:Label ID="Label1" runat="server" Text=""></asp:Label> <br /> <br /> <asp:Label ID="Label2" runat="server" Text=""></asp:Label> <br /> <br /> <asp:Label ID="Label3" runat="server" Text=""></asp:Label> <br /> <br /> <asp:Label ID="Label4" runat="server" Text=""></asp:Label> <br /> <br /> </div> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta charset="utf-8" /> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#3366CC" BorderWidth="1px" CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" ForeColor="#003399" Height="200px" Width="220px"> <DayHeaderStyle BackColor="#99CCCC" ForeColor="#336666" Height="1px"></DayHeaderStyle> <NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF"></NextPrevStyle> <OtherMonthDayStyle ForeColor="#999999"></OtherMonthDayStyle> <SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99"></SelectedDayStyle> <SelectorStyle BackColor="#99CCCC" ForeColor="#336666"></SelectorStyle> <TitleStyle BackColor="#003399" BorderColor="#3366CC" BorderWidth="1px" Font-Bold="True" Font-Size="10pt" ForeColor="#CCCCFF" Height="25px"></TitleStyle> <TodayDayStyle BackColor="#99CCCC" ForeColor="White"></TodayDayStyle> <WeekendDayStyle BackColor="#CCCCFF"></WeekendDayStyle> </asp:Calendar> <br /> <br /> <asp:Button ID="Button1" runat="server" Text="OK" OnClick="Button1_Click" /> <asp:Button ID="Button2" runat="server" Text="Clear" OnClick="Button2_Click" /> <br /> <br /> <asp:Label ID="Label1" runat="server" Text=""></asp:Label> <br /> <br /> <asp:Label ID="Label2" runat="server" Text=""></asp:Label> <br /> <br /> <asp:Label ID="Label3" runat="server" Text=""></asp:Label> <br /> <br /> <asp:Label ID="Label4" runat="server" Text=""></asp:Label> <br /> <br /> </div> </form> </body> </html>
Default.aspx.cs
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Date : " + Calendar1.SelectedDate.Date.ToString(); Label2.Text = "Year : " + Calendar1.SelectedDate.Year.ToString(); Label3.Text = "Month : " + Calendar1.SelectedDate.Month.ToString(); Label4.Text = "Day : " + Calendar1.SelectedDate.Day.ToString(); } protected void Button2_Click(object sender, EventArgs e) { Label1.Text = string.Empty; Label2.Text = string.Empty; Label3.Text = string.Empty; Label4.Text = string.Empty; } }
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Date : " + Calendar1.SelectedDate.Date.ToString(); Label2.Text = "Year : " + Calendar1.SelectedDate.Year.ToString(); Label3.Text = "Month : " + Calendar1.SelectedDate.Month.ToString(); Label4.Text = "Day : " + Calendar1.SelectedDate.Day.ToString(); } protected void Button2_Click(object sender, EventArgs e) { Label1.Text = string.Empty; Label2.Text = string.Empty; Label3.Text = string.Empty; Label4.Text = string.Empty; } }