www.pudn.com > ptymdate.rar > Calendar.cs


using System; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.HtmlControls; 
using System.ComponentModel; 
using System.Web.UI.Design; 
using System.Drawing.Design; 
using System.Drawing; 
using System.Globalization; 
 
 
namespace WFNetCtrl 
{ 
	//============高处不胜寒.Net日期控件 1.1版================= 
	//     
	//                   ''' 
	//                  (0 0) 
	//      +-----oOO----(_)------------+ 
	//      |                           | 
	//      |   作者:高处不胜寒         | 
	//      |   QQ:28767360             | 
	//      |   AspXCn QQ群:           |  
	//      |   类型:Wap版             | 
	//      |   更新时间:2005-07-23   | 
	//      |                           | 
	//      +------------------oOO------+ 
	//                 |__|__| 
	//                  || || 
	//                 ooO Ooo   
	// 
	//=========================================== 
	///  
	/// Calendar 的摘要说明。 
	///  
	public class Calendar : System.Web.UI.WebControls.TextBox 
	{ 
		bool write; 
 
		public Calendar() 
		{ 
			// 
			// TODO: 在此处添加构造函数逻辑 
			// 
		} 
		[Description("是否可以写入日期")] 
		public bool IsWrite 
		{ 
			get 
			{ 
				return write; 
			} 
 
			set 
			{ 
				write= value; 
			} 
		} 
		private const string str_Js=@" 
         
        "; 
		private const string ScriptKey="HcTextBoxClientScrptKeyWord"; 
		///  
		/// 将此控件呈现给指定的输出参数。 
		///  
		///  要写出到的 HTML 编写器  
		 
		protected override void OnPreRender(System.EventArgs e) 
		{ 
			Page.RegisterStartupScript(ScriptKey,str_Js); 
		} 
		protected override void AddAttributesToRender(HtmlTextWriter output)  
		{ 
			output.AddAttribute("onfocus","setday(this);"); 
			if (this.write==false) 
			{ 
				//output.AddAttribute("onkeypress","return false;"); 
				//output.AddAttribute("onselectstart","return false;"); 
			} 
			base.AddAttributesToRender(output); 
		} 
	} 
}