• 编写带有节日的日历


     

     

    using System;
    using
    System.Data;
    using
    System.Configuration;
    using
    System.Collections;
    using
    System.Web;
    using
    System.Web.Security;
    using
    System.Web.UI;
    using
    System.Web.UI.WebControls;
    using
    System.Web.UI.WebControls.WebParts;
    using
    System.Web.UI.HtmlControls;

    public partial class
    CalendarThree : System.Web.UI.Page
    {
        String[][] holidays
    = new String[13
    ][];
       
    protected void Page_Load(object
    sender, EventArgs e)
        {
           
    for (int n = 0; n < 13; n++
    )
                holidays[n]
    = new String[32
    ];

            holidays[
    1][1] = "元旦"
    ;
            holidays[
    2][14] = "情人节"
    ;
            holidays[
    3][8] = "妇女节"
    ;
            holidays[
    3][12] = "植树节"
    ;
            holidays[
    4][1] = "愚人节"
    ;
            holidays[
    5][1] = "劳动节"
    ;
            holidays[
    5][4] = "青年节"
    ;
            holidays[
    5][12] = "护士节"
    ;
            holidays[
    5][14] = "母亲节"
    ;
            holidays[
    5][14] = "助残日"
    ;
            holidays[
    6][1] = "国际儿童节"
    ;
            holidays[
    6][5] = "环境保护日"
    ;
            holidays[
    6][18] = "父亲节"
    ;
            holidays[
    6][26] = "国际禁毒日"
    ;
            holidays[
    7][1] = "中共诞辰"
    ;
            holidays[
    8][1] = "建军节"
    ;
            holidays[
    9][10] = "教师节"
    ;
            holidays[
    10][1] = "国庆节"
    ;
            holidays[
    11][23] = "感恩节"
    ;
            holidays[
    12][1] = "艾滋病日"
    ;
            holidays[
    12][12] = "西安事变"
    ;
            holidays[
    12][25] = "圣诞节"
    ;
        }
       
    protected void Calendar1_DayRender(object
    sender, DayRenderEventArgs e)
        {
            CalendarDay d
    =
    ((DayRenderEventArgs)e).Day;
            TableCell c
    =
    ((DayRenderEventArgs)e).Cell;

           
    if
    (e.Day.IsOtherMonth)
            {
                e.Cell.Controls.Clear();
            }
           
    else

            {
               
    try
                {
                   
    string Hol = holidays[e.Day.Date.Month][e.Day.Date.Day];

                   
    if (Hol != string
    .Empty)
                        e.Cell.Controls.Add(
    new LiteralControl("<br><font color=blue size=2>" + Hol + "</font>"
    ));
                }
               
    catch
    (Exception exc)
                {
                    Response.Write(exc.ToString());
                }
            }
        }
    }

    感谢来访,共同学习!
  • 相关阅读:
    高速排序(递归与分治的思想)
    silverlight wcf mvvm
    黑龙江绿色食品青年电商销售大赛开幕,绿色巨人最终发力做电商了
    ecnu 1244
    可穿戴KEY带来的身份认证的革命
    深入理解7816(3)-----关于T=0 【转】
    深入理解7816(1)---- 关于F/D和etu【转】
    深入理解7816(2)---关于ATR【转】
    [Android 编译(一)] Ubuntu 16.04 LTS 成功编译 Android 6.0 源码教程
    Ubuntu16.04下搭建开发环境及编译tiny4412 Android系统【转】
  • 原文地址:https://www.cnblogs.com/dingxiaowei/p/3058838.html
Copyright © 2020-2023  润新知