calendar22.aspx

来自「《精通ASP.NET网络编程》附带实例」· ASPX 代码 · 共 67 行

ASPX
67
字号
<html>
<head>
    <script language="C#" runat="server">

        void Date_Selected(object s, EventArgs e) {
        
            switch (Calendar1.SelectedDates.Count) {
            
                case (0):   //None
                    Label1.Text = "No dates are currently selected";
                    break;
                case (1):   //Day
                    Label1.Text = "The selected date is " + Calendar1.SelectedDate.ToShortDateString();
                    break;
                case (7):   //Week
                    Label1.Text = "The selection is a week beginning " + Calendar1.SelectedDate.ToShortDateString();
                    break;
                default:    //Month
                    Label1.Text = "The selection is a month beginning " + Calendar1.SelectedDate.ToShortDateString();
                  break;
            }
        }

    </script>
</head>

<body>

    <h3><font face="Verdana">Selection Link Text</font></h3>
    <p>

    <form runat=server>

        <p>
        <asp:Calendar id=Calendar1 runat="server"
            onselectionchanged="Date_Selected"
            DayNameFormat="Short"
            SelectionMode="DayWeekMonth"
            Font-Name="Verdana;Arial" Font-Size="12px"
            Height="180px" Width="230px"
            TodayDayStyle-Font-Bold="True"
            DayHeaderStyle-Font-Bold="True"
            OtherMonthDayStyle-ForeColor="gray"
            TitleStyle-BackColor="#3366ff"
            TitleStyle-ForeColor="white"
            TitleStyle-Font-Bold="True"
            SelectedDayStyle-BackColor="#ffcc66"
            SelectedDayStyle-Font-Bold="True"
            NextPrevFormat="ShortMonth"
            NextPrevStyle-ForeColor="white"
            NextPrevStyle-Font-Size="10px"
            SelectorStyle-BackColor="#99ccff"
            SelectorStyle-ForeColor="navy"
            SelectorStyle-Font-Size="9px"
            SelectWeekText = "week"
            SelectMonthText = "month"
            />

        <p>
        <asp:Label id=Label1 runat="server" />
    </form>
</body>
</html>



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?