最近我在做这样一个小系统(公司休假安排),以日历控件为主
其功能描述如下:
1.可以在日历控件中任意选择本月内的某一天做为休假日,并用相应的颜色做标记.
2.把国家一些法定节日在日历中标记出来,(如:五一(7天),元旦(3天),国庆(7天))因  为其放假天数是固定的,所以在界面上要实现只需要用户一个确认功能,比如:当用户确认五一放  假,则在日历控件中自动将这7天用休假颜色标记.
3.对星期六和星期天也是要确认是否作为休假.但以年为单位.比如:要确定2005的周六全休假
  那么当用户确认以后,日历自动将本年内所有周六的日期全部标记为休假日颜色标记.我现在实现了功能1.后面两个不知道怎么处理了.忘高手们给小弟一个解决办法,谢谢了!最好有原代码的!万分感谢.我没什么经验,才入门的那中.

解决方案 »

  1.   

    不建议使用.net环境提供的日历控件现在网上有很多的js写的日历控件,很好用
      

  2.   

    国家一些法定节日在日历中标记出来<html>
    <head>
        <script language="VB" runat="server">        Dim holidays(12,31) as String        Sub Page_Load(sender As Object, e As EventArgs)
                holidays(1,1)   = "New Year's Day"
                  holidays(1,26)  = "Australia Day"
                holidays(2,2)   = "Groundhog Day"
                holidays(2,14)  = "Valentine's Day"
                holidays(3,17)  = "St. Patrick's Day"
                holidays(4,1)   = "April Fool's Day"
                holidays(5,1)   = "May Day"
                holidays(6,15)  = "My Birthday"
                holidays(7,15)  = "My Anniversary"
                holidays(8,15)  = "My Mother's Birthday"
                holidays(9,24)  = "Autumnal Equinox"
                holidays(12,26) = "Boxing Day"
            End Sub        Sub Calendar1_DayRender(sender As Object, e As DayRenderEventArgs)            Dim d as CalendarDay
                Dim c as TableCell            d = e.Day
                c = e.Cell            If d.IsOtherMonth Then
                    c.Controls.Clear
                Else
                    Try
                        Dim Hol As String = holidays(d.Date.Month,d.Date.Day)                    If Hol <> "" Then
                            c.Controls.Add(new LiteralControl("<br>" + Hol))
                        End If
                    Catch exc as Exception
                        Response.Write (exc.ToString())
                    End Try
                End If
            End Sub        Sub Date_Selected(sender As Object, e As EventArgs)
                Label1.Text = "Selected date is: " + Calendar1.SelectedDate.ToShortDateString
            End Sub    </script></head><body>    <h3><font face="Verdana">Adding Custom Content to Calendar</font></h3>
        <p><p>    <form runat=server>        <asp:Calendar id=Calendar1 runat="server"
                ondayrender="Calendar1_DayRender"
                onselectionchanged="Date_Selected"
                ShowGridLines="true"
                BorderWidth="1"
                Font-Name="Verdana"
                Font-Size="9px"
                Width="500px"
                VisibleDate="01/01/2000"
                TitleStyle-BackColor="Gainsboro"
                TitleStyle-Font-Size="12px"
                TitleStyle-Font-Bold="true"
                DayStyle-VerticalAlign="Top"
                DayStyle-Height="50px"
                DayStyle-Width="14%"
                SelectedDate="1/1/0001"
                SelectedDayStyle-BackColor="Navy"
                />        <p>
            <asp:Label id=Label1 runat="server" />
        </form></body>
    </html>