标题:怎样在日历控件中怎么添加特殊节日
只看楼主
doujiang
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2008-4-7
 问题点数:0 回复次数:3 
怎样在日历控件中怎么添加特殊节日
在日历控件中怎么把自定义的节日加上显示呢?
搜索更多相关主题的帖子: 控件中 日历 节日 定义 
2008-04-07 23:38
sldtk1
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:20
帖 子:624
专家分:258
注 册:2006-5-4
得分:0 
string[,] holiday = new string[13, 32];

    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        holiday[7, 1] = "党的生日";
        CalendarDay c = e.Day;
        TableCell t = e.Cell;

        if (c.IsOtherMonth)
            t.Controls.Clear();
        else
        {
            string tmp = holiday[c.Date.Month, c.Date.Day];
            if(tmp!=null)
                t.Controls.Add(new LiteralControl("<br>"+tmp));

        }
    }
2008-04-08 01:55
srym
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2008-4-2
得分:0 
string[,] myday;
    public void CreateDay()
    {
        myday = new string[13, 32];
        myday[1, 1] = "元旦";
        myday[2, 14] = "情人节";
        myday[3, 8] = "妇女节";
        myday[4, 1] = "愚人节";
        myday[5, 1] = "劳动节";
        myday[6, 1] = "儿童节";
        myday[7, 1] = "建党节";
        myday[8, 1] = "建军节";
        myday[9, 10] = "教师节";
        myday[10, 1] = "国庆节";
        myday[12, 24] = "圣诞节";
    }
    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        CreateDay();
        if (myday[e.Day.Date.Month, e.Day.Date.Day] != null)
        {
            Literal lbl = new Literal();
            lbl.Text = "<br>"+myday[e.Day.Date.Month, e.Day.Date.Day];

            e.Cell.Controls.Add(lbl);
        }
        
    }

这个家伙狠懒,没有留下任何签名!
2008-04-08 08:58
doujiang
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2008-4-7
得分:0 
十分感谢!
2008-04-08 11:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-207642-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.173668 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved