我网页上的代码:
aspx
<asp:calendar id="Calendar1" CellPadding="2" Width="160px" OnDayRender="Calendar1_DayRender" TitleStyle-BackColor="#ffffff" TitleStyle-ForeColor="#ffffff" BorderColor="#aaaaaa" TitleFormat="MonthYear" DayHeaderStyle-BackColor="#5e715e" OtherMonthDayStyle-ForeColor="#cccccc" DayNameFormat="Full" runat="server" NextPrevStyle-ForeColor="#ffffff" CellSpacing="1" DayHeaderStyle-ForeColor="#ffffff" SelectionMode="None"></asp:calendar>
cs
private System.Threading.Thread t;
private CultureInfo oldCulture;
protected DataSet dsHolidays; protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Calendar1.VisibleDate = DateTime.Today;
FillHolidayDataset();
}
} protected void FillHolidayDataset()
{
dsHolidays = GetCurrentMonthData();
} protected DataSet GetCurrentMonthData()
{
DataSet dsMonth = new DataSet();
dsMonth.ReadXml(Utility.GetRealFile("/Holiday.xml")); return dsMonth;
} protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
DateTime nextDate; if (e.Day.Date.DayOfWeek.ToString() == "Sunday")
{
e.Cell.BackColor = System.Drawing.Color.LightGray;
e.Cell.ForeColor = System.Drawing.Color.Red;
e.Cell.Font.Bold = true;
}
if (e.Day.IsOtherMonth)
{
e.Cell.Controls.Clear();
e.Cell.BackColor = System.Drawing.Color.White;
}
if (dsHolidays != null)
{
foreach (DataRow dr in dsHolidays.Tables[0].Rows)
{
nextDate = Convert.ToDateTime(dr["day"].ToString());
if (nextDate == e.Day.Date)
{
e.Cell.BackColor = System.Drawing.Color.LightGray;
e.Cell.ForeColor = System.Drawing.Color.Red;
e.Cell.Font.Bold = true;
}
}
}
} protected void Calendar1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
{
FillHolidayDataset();
} private void Calendar1_PreRender(object sender, System.EventArgs e)
{ t = System.Threading.Thread.CurrentThread;
oldCulture = t.CurrentCulture;
CultureInfo newci = (CultureInfo)oldCulture.Clone();
newci.DateTimeFormat.DayNames = new string[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
newci.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday;
t.CurrentCulture = newci; } #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
} /// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Calendar1.DayRender += new System.Web.UI.WebControls.DayRenderEventHandler(this.Calendar1_DayRender);
this.Calendar1.PreRender += new System.EventHandler(this.Calendar1_PreRender);
this.Load += new System.EventHandler(this.Page_Load);
}
aspx
<asp:calendar id="Calendar1" CellPadding="2" Width="160px" OnDayRender="Calendar1_DayRender" TitleStyle-BackColor="#ffffff" TitleStyle-ForeColor="#ffffff" BorderColor="#aaaaaa" TitleFormat="MonthYear" DayHeaderStyle-BackColor="#5e715e" OtherMonthDayStyle-ForeColor="#cccccc" DayNameFormat="Full" runat="server" NextPrevStyle-ForeColor="#ffffff" CellSpacing="1" DayHeaderStyle-ForeColor="#ffffff" SelectionMode="None"></asp:calendar>
cs
private System.Threading.Thread t;
private CultureInfo oldCulture;
protected DataSet dsHolidays; protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Calendar1.VisibleDate = DateTime.Today;
FillHolidayDataset();
}
} protected void FillHolidayDataset()
{
dsHolidays = GetCurrentMonthData();
} protected DataSet GetCurrentMonthData()
{
DataSet dsMonth = new DataSet();
dsMonth.ReadXml(Utility.GetRealFile("/Holiday.xml")); return dsMonth;
} protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
DateTime nextDate; if (e.Day.Date.DayOfWeek.ToString() == "Sunday")
{
e.Cell.BackColor = System.Drawing.Color.LightGray;
e.Cell.ForeColor = System.Drawing.Color.Red;
e.Cell.Font.Bold = true;
}
if (e.Day.IsOtherMonth)
{
e.Cell.Controls.Clear();
e.Cell.BackColor = System.Drawing.Color.White;
}
if (dsHolidays != null)
{
foreach (DataRow dr in dsHolidays.Tables[0].Rows)
{
nextDate = Convert.ToDateTime(dr["day"].ToString());
if (nextDate == e.Day.Date)
{
e.Cell.BackColor = System.Drawing.Color.LightGray;
e.Cell.ForeColor = System.Drawing.Color.Red;
e.Cell.Font.Bold = true;
}
}
}
} protected void Calendar1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
{
FillHolidayDataset();
} private void Calendar1_PreRender(object sender, System.EventArgs e)
{ t = System.Threading.Thread.CurrentThread;
oldCulture = t.CurrentCulture;
CultureInfo newci = (CultureInfo)oldCulture.Clone();
newci.DateTimeFormat.DayNames = new string[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
newci.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday;
t.CurrentCulture = newci; } #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
} /// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Calendar1.DayRender += new System.Web.UI.WebControls.DayRenderEventHandler(this.Calendar1_DayRender);
this.Calendar1.PreRender += new System.EventHandler(this.Calendar1_PreRender);
this.Load += new System.EventHandler(this.Page_Load);
}
解决方案 »
- 哪位高手知道不用COM组件读写Word文档
- ASP.NET问题
- 动态新闻内容页如何分页?
- 在asp.net中如何添加框架?
- .net 的web打包安装後由于权限的问题无法读取ACCESS数据库如何用C#来修改权限(windows xp sp2)
- 怎么把dataset里面的多个结构相同的datatable合并到一个datatable 里面啊
- 如何中止当前运行的程序??就是什么都不显示~
- winxp家庭版如何配置ASP环境
- asp.net中使用msgbox得问题,谁知道?
- 生成excel文件
- 如何将我页面中的文本复制到其他的网页上去?
- 网银基础架构巨大数量的并发访问和交易处理,及I/O处理的问题?
请问在哪里改呢?我在页面上改成
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">也没有用。
我想把年月显示成:APR.2010