using System;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebBase
{
///
/// Calendar 的摘要说明。
///
public class Calendar : TextBox
{
public Calendar()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
#region Javascript
private const string str_Js=@"
";
#endregion
private const string ScriptKey="HcTextBoxClientScrptKeyWord";
///
/// 将此控件呈现给指定的输出参数。
///
/// 要写出到的 HTML 编写器
protected override void OnPreRender(EventArgs e)
{
Page.RegisterStartupScript(ScriptKey,str_Js);
}
protected override void AddAttributesToRender(HtmlTextWriter output)
{
output.AddAttribute("onfocus","setday(this);");
base.AddAttributesToRender(output);
}
public DateTime Date
{
get
{
return Convert.ToDateTime(this.Text);
}
set
{
int year,month,day;
year = value.Year;
month = value.Month;
day = value.Day;
string str = Convert.ToString(year)+"-";
if( month < 10) str += "0";
str += Convert.ToString(month)+"-";
if( day < 10) str += "0";
str += Convert.ToString(day);
this.Text= str;
}
}
}
}