==> [FrmCalendar.aspx] 소스 및 디자인

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FrmCalendar.aspx.cs" Inherits="FrmCalendar" %>

 

<!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>

    <form id="form1" runat="server">

    <div>

   

        <asp:Calendar ID="Calendar1" runat="server"

            onselectionchanged="Calendar1_SelectionChanged"></asp:Calendar>

        <hr />

        <asp:Label ID="lblDate" runat="server" Text=""></asp:Label>

        <hr />

       

        <asp:Calendar ID="Calendar2" runat="server"

            SelectionMode="DayWeekMonth"

            onselectionchanged="Calendar2_SelectionChanged"></asp:Calendar>

        <asp:Label ID="lblDates" runat="server" Text=""></asp:Label>

        <br />

       

        <asp:Calendar ID="Calendar3" runat="server" BackColor="#FFFFCC"

            BorderColor="#FFCC66" BorderWidth="1px" DayNameFormat="Shortest"

            Font-Names="Verdana" Font-Size="8pt" ForeColor="#663399" Height="310px"

            NextMonthText="다음달" PrevMonthText="이전달" ShowGridLines="True" Width="607px">

            <SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />

            <SelectorStyle BackColor="#FFCC66" />

            <TodayDayStyle BackColor="#FFCC66" ForeColor="White" />

            <OtherMonthDayStyle ForeColor="#CC9966" />

            <NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />

            <DayHeaderStyle BackColor="#FFCC66" Font-Bold="True" Height="1px" />

            <TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"

                ForeColor="#FFFFCC" />

        </asp:Calendar>

       

    </div>

    </form>

</body>

</html>

 

 


 

 

-------------------------------------------------------------------------------------

 


==> [FrmCalendar.aspx.cs] 소스

 


using System;

 

public partial class FrmCalendar : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

 

    }

    protected void Calendar1_SelectionChanged(object sender, EventArgs e)

    {

        // 현재 선택된 날짜/시간값을 출력

        this.lblDate.Text = Calendar1.SelectedDate.ToLongDateString();

    }

    protected void Calendar2_SelectionChanged(object sender, EventArgs e)

    {

        // 현재 선택된 범위의 날짜값을 출력

        string s = "";

        foreach (DateTime item in Calendar2.SelectedDates)

            {

            s += item.ToShortDateString() + "<br />";                

            }

        lblDates.Text = s;

    }

}

 

 

-------------------------------------------------------------------------------------

 


[실행결과]

--> 실행해보면 웹 페이지에 3개의 "캘린더 컨트롤"이 출력되는데, 맨 위에 있는 캘린더는 [FrmCalendar.aspx.cs] 소스코드에서 "현재 선택된 날짜/시간값을 출력"하도록 하였고(캘린더에서 특정한 날짜를 마우스로 클릭(선택)하면 캘린더 바로아래에 있는 "레이블"에 선택한 날짜가 출력된다.), 두번째의 캘린더는 "현재 선택된 범위의 날짜값을 출력"하도록 하였다.(두번째 캘린더에서 맨왼쪽줄에 있는 여러개의 "꺽쇠(>)표시"중 하나를 마우스로 클릭(선택)하면 "해당되는 행"의 "선택된 범위의 날짜들"이 두번째 캘린더 아래의 "레이블"에 모두 출력된다.)

 

 

 


 

'.NET프로그래밍 > ASP.NET 3.5 SP1' 카테고리의 다른 글

FrmXml (XML 컨트롤)  (0) 2009.10.08
FrmAdRotator (광고 컨트롤)  (0) 2009.10.07
FrmInputControl  (0) 2009.10.07
FrmHiddenField  (0) 2009.10.07
FrmLinkButton  (0) 2009.10.07
Posted by holland14
: