吴旭晓个人博客 繁体中文 简体中文

首页| 日志 |JAVA |ASP |PHP |Android |IOS |ASP.NET |JavaScript |DIV+CSS |SEO |taobaoke |饼哥语录
繁体中文 简体中文

ASP.NET日历控件

1、新建一个aspx页面,把calender控件拉进来。  
2、第一步是外观设置,这个根据你的需要,只需对它的相关属性做一些调整即可。可以调整如下图:

       属性设置如下:
  <asp:calendar id="Calendar1" CellPadding="2" Width="160px" TitleStyle-BackColor="#000000"      
    BorderColor="#aaaaaa"
    DayHeaderStyle-BackColor="#5e715e"
    OtherMonthDayStyle-ForeColor="#cccccc"
    DayNameFormat="Full"
    runat="server"
    TitleStyle-ForeColor="#ffffff"
    NextPrevStyle-ForeColor="#ffffff"
    CellSpacing="1"
    WeekendDayStyle-BackColor="#eeeeee"
    DayHeaderStyle-ForeColor="#ffffff"
    SelectionMode="None"
    TodayDayStyle-BorderColor="#5e715e"
    TodayDayStyle-BorderWidth="1"
    TodayDayStyle-Font-Bold="true"
    TodayDayStyle-ForeColor="#5e715e"
/>
     第二步是对内部功能的调整,这个工作主要集中在以下事件的处理上。
  
     PreRender:当服务器控件将要呈现给其包含的Page对象时发生。
private void Calendar1_PreRender(object sender, System.EventArgs e)
  {
   Thread threadCurrent = Thread.CurrentThread;
   CultureInfo ciNew = (CultureInfo)threadCurrent.CurrentCulture.Clone();
   ciNew.DateTimeFormat.DayNames = new string[]{"日","一","二","三","四","五","六"};
   ciNew.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday;
   threadCurrent.CurrentCulture = ciNew;
  }

                以上代码改变了星期名称的显示。你只需改变字符数组的值就能改名称显示。

作者:吴旭晓 | 来源:个人博客 | 点击量:5197 | 发布时间:2010-09-09
最新留言 | 返回上一页 | 返回首页

相关文章:

版权所有:吴旭晓个人博客 Copyright © 2013-2023 个人博客