日历控件默认的星期几显示都是中文的,我想把星期几的显示成为英文的,但是在论坛中看到有人这么写:private void Calendar1_PreRender(object sender, System.EventArgs e)
{
Thread threadCurrent = Thread.CurrentThread;
CultureInfo ciNew = (CultureInfo)threadCurrent.CurrentCulture.Clone();
ciNew.DateTimeFormat.DayNames = new string[]{"sun","mon","tu","fri","we","tu","sat"};
ciNew.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday;
threadCurrent.CurrentCulture = ciNew;
}我试了一下,但是报错,说Thread、CultureInfo、ciNew、threadCurrent等等找不到类型或命名空间,是否缺少using指令或程序集引用。请问这是怎么回事?
{
Thread threadCurrent = Thread.CurrentThread;
CultureInfo ciNew = (CultureInfo)threadCurrent.CurrentCulture.Clone();
ciNew.DateTimeFormat.DayNames = new string[]{"sun","mon","tu","fri","we","tu","sat"};
ciNew.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday;
threadCurrent.CurrentCulture = ciNew;
}我试了一下,但是报错,说Thread、CultureInfo、ciNew、threadCurrent等等找不到类型或命名空间,是否缺少using指令或程序集引用。请问这是怎么回事?
using System.Globalization;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Threading;
using System.Globalization;
namespace myaspnet
{
/// <summary>
/// calendar02 的摘要说明。
/// </summary>
public class calendar02 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Calendar Calendar1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
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;
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
}
}