c# asp.net 日历控件(9)

Calendor控件为用户显示一个日历。它还提供日历选取功能。Calendor控件必须放在Form或者Panel控件内,或者控件的模板内。在添加Calendor控件之后。它一次显示一月的日期。另外,它还显示该月之前的一周和之后的一周。因此,可以显示六周。
 FirstDateOfWeek 设置要在控件中的第一天列显示一周的某天
 NextMonthText  设置下一个月导航控件的显示文本
 PrevMonthText  设置前一个月导航控件的现实文本
 SelectDeta
 设置当前日期
 SelectionMode  指定用户可以选择单日,一周还是整月的日期选择模式
 SelectionChanged  当用户通过单击日期选择器控件选择某一天、一周或整月是发生
 属性
 说明
   
实例:通过日历单击某一天可以是实现对用户输入的记录(这是整体思路),当用户再次点击时会出现所提交的东西,不过这个实例不是这样。这个实例只是了解控件的基本作用。
html代码如下:
<div>
        
                <asp:Calendar ID= "Calendar1" runat= "server" BackColor= "#FFFFCC"
                        BorderColor= "#FFCC66" BorderWidth= "1px" DayNameFormat= "Shortest"
                        Font-Names= "Verdana" Font-Size= "8pt" ForeColor= "#663399" Height= "200px"
                        onselectionchanged= "Calendar1_SelectionChanged" SelectionMode= "DayWeek"
                        ShowGridLines= "True" Width= "220px">
                        <SelectedDayStyle BackColor= "#CCCCFF" Font-Bold= "True" />
                        <SelectorStyle BackColor= "#669999" />
                        <WeekendDayStyle BackColor= "#CC66FF" BorderColor= "#00CC66" ForeColor= "#333300"
                                HorizontalAlign= "Center" Wrap= "True" />
                        <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>
                <asp:Label ID= "Label1" runat= "server" Visible= "False"
                        Width= "220px" BackColor= "#FFCCFF" Font-Names= "华文楷体" Font-Overline= "False"
                        Font-Size= "Medium" ForeColor= "#003366"></asp:Label>
                <br />
                <asp:TextBox ID= "TextBox1" runat= "server" Visible= "False"></asp:TextBox>
                <asp:Button ID= "Button1" runat= "server" onclick= "Button1_Click" Text= "提交"
                        Visible= "False" />
        
        </div>
后台代码:

         public partial class _Default : System.Web.UI.Page
        {
                 protected void Page_Load( object sender, EventArgs e)
                {

                }


                 protected void Calendar1_SelectionChanged( object sender, EventArgs e)
                {
                                 this.Calendar1.SelectionChanged += new EventHandler(Calendar1_SelectionChanged);
                                TextBox1.Visible = true; Button1.Visible = true; Label1.Visible = true;
                                 this.Label1.Text = Calendar1.SelectedDate.ToShortDateString();
                                Calendar1.Visible = false;


                    
                }

                 protected void Button1_Click( object sender, EventArgs e)
                {
        
                        
                                Label1.Visible = true;
                                 this.Label1.Text = this.TextBox1.Text;
                                TextBox1.Visible = false; Button1.Visible = false;
效果图:

自己对日历控件的了解还不够,加油

你可能感兴趣的:(C#,职场,asp.net,日历,控件,休闲)