asp.net中calendar控件 如何显示英文年月?
我网页上的代码: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);
}
--------------------编程问答-------------------- 貌似要改页面的语言选项。。。以前遇到过 --------------------编程问答-------------------- 好像有个glob设置区划的。具体的楼主自己搜一下吧。 --------------------编程问答--------------------
请问在哪里改呢?我在页面上改成
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">也没有用。 --------------------编程问答-------------------- 现在的效果是这样的
我想把年月显示成:APR.2010
补充:.NET技术 , ASP.NET