Calendor控件为用户显示一个日历。它还提供日历选取功能。Calendor控件必须放在Form或者Panel控件内,或者控件的模板内。在添加Calendor控件之后。它一次显示一月的日期。另外,它还显示该月之前的一周和之后的一周。因此,可以显示六周。

 FirstDateOfWeek 设置要在控件中的第一天列显示一周的某天
 NextMonthText  设置下一个月导航控件的显示文本
 PrevMonthText  设置前一个月导航控件的现实文本
 SelectDeta
 设置当前日期
 SelectionMode  指定用户可以选择单日,一周还是整月的日期选择模式
 SelectionChanged  当用户通过单击日期选择器控件选择某一天、一周或整月是发生
 属性
 说明
   

实例:通过日历单击某一天可以是实现对用户输入的记录(这是整体思路),当用户再次点击时会出现所提交的东西,不过这个实例不是这样。这个实例只是了解控件的基本作用。
html代码如下:

c# asp.net 日历控件(9)<div>
c# asp.net 日历控件(9)        
c# asp.net 日历控件(9)                <asp:Calendar ID="Calendar1" runat="server" BackColor="#FFFFCC"
c# asp.net 日历控件(9)                        BorderColor="#FFCC66" BorderWidth="1px" DayNameFormat="Shortest"
c# asp.net 日历控件(9)                        Font-Names="Verdana" Font-Size="8pt" ForeColor="#663399" Height="200px"
c# asp.net 日历控件(9)                        onselectionchanged="Calendar1_SelectionChanged" SelectionMode="DayWeek"
c# asp.net 日历控件(9)                        ShowGridLines="True" Width="220px">
c# asp.net 日历控件(9)                        <SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
c# asp.net 日历控件(9)                        <SelectorStyle BackColor="#669999" />
c# asp.net 日历控件(9)                        <WeekendDayStyle BackColor="#CC66FF" BorderColor="#00CC66" ForeColor="#333300"
c# asp.net 日历控件(9)                                HorizontalAlign="Center" Wrap="True" />
c# asp.net 日历控件(9)                        <TodayDayStyle BackColor="#FFCC66" ForeColor="White" />
c# asp.net 日历控件(9)                        <OtherMonthDayStyle ForeColor="#CC9966" />
c# asp.net 日历控件(9)                        <NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />
c# asp.net 日历控件(9)                        <DayHeaderStyle BackColor="#FFCC66" Font-Bold="True" Height="1px" />
c# asp.net 日历控件(9)                        <TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"
c# asp.net 日历控件(9)                                ForeColor="#FFFFCC" />
c# asp.net 日历控件(9)                </asp:Calendar>
c# asp.net 日历控件(9)                <asp:Label ID="Label1" runat="server" Visible="False"
c# asp.net 日历控件(9)                        Width="220px" BackColor="#FFCCFF" Font-Names="华文楷体" Font-Overline="False"
c# asp.net 日历控件(9)                        Font-Size="Medium" ForeColor="#003366"></asp:Label>
c# asp.net 日历控件(9)                <br />
c# asp.net 日历控件(9)                <asp:TextBox ID="TextBox1" runat="server" Visible="False"></asp:TextBox>
c# asp.net 日历控件(9)                <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="提交"
c# asp.net 日历控件(9)                        Visible="False" />
c# asp.net 日历控件(9)        
c# asp.net 日历控件(9)        </div>

后台代码:

c# asp.net 日历控件(9)
        public partial class _Default : System.Web.UI.Page
c# asp.net 日历控件(9)        {
c# asp.net 日历控件(9)                protected void Page_Load(object sender, EventArgs e)
c# asp.net 日历控件(9)                {
c# asp.net 日历控件(9)
                }
c# asp.net 日历控件(9)

 

c# asp.net 日历控件(9)                protected void Calendar1_SelectionChanged(object sender, EventArgs e)
c# asp.net 日历控件(9)                {
c# asp.net 日历控件(9)                                this.Calendar1.SelectionChanged += new EventHandler(Calendar1_SelectionChanged);
c# asp.net 日历控件(9)                                TextBox1.Visible = true; Button1.Visible = true; Label1.Visible = true;
c# asp.net 日历控件(9)                                this.Label1.Text = Calendar1.SelectedDate.ToShortDateString();
c# asp.net 日历控件(9)                                Calendar1.Visible = false;
c# asp.net 日历控件(9)

c# asp.net 日历控件(9)                    
c# asp.net 日历控件(9)                }
c# asp.net 日历控件(9)
                protected void Button1_Click(object sender, EventArgs e)
c# asp.net 日历控件(9)                {
c# asp.net 日历控件(9)        
c# asp.net 日历控件(9)                        
c# asp.net 日历控件(9)                                Label1.Visible = true;
c# asp.net 日历控件(9)                                this.Label1.Text = this.TextBox1.Text;
c# asp.net 日历控件(9)                                TextBox1.Visible = false; Button1.Visible = false;

效果图:c# asp.net 日历控件(9)

 

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

相关文章:

  • 2021-09-15
  • 2022-01-19
  • 2022-02-16
  • 2021-12-03
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-03
  • 2022-12-23
  • 2022-03-03
  • 2022-02-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案