//========================================================================== //名称: zyq.webcontrols.cultural.datetimepick.datetimepicklabel // asp.net服务控件 //版本: 1.0.0.0 //作者: 张宇庆 //日期: 2003.2.12 //email: [email protected] //说明: 本控件及源代码只是为《计算机世界》开发者俱乐部asp.net论坛学习如何开发asp.net // 服务器端控件而开发。未经本人同意请勿用作商业用途。 // //========================================================================== using system; using system.globalization; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.componentmodel; using zyq; using zyq.webcontrols.cultural.datetimepick; namespace zyq.webcontrols.cultural.datetimepick {
/// <summary> /// datetimepicklabel由system.web.ui.webcontrols.label继承。 /// 使用system.globalization.cultureinfo类来显示格式化了的时间。 /// </summary> [toolboxdata("<{0}:datetimepicklabel runat=server></{0}:datetimepicklabel>")] public class datetimepicklabel : system.web.ui.webcontrols.label { #region 私有变量定义 private bool _autofit; private datetime _dt; private string text; private dateformatoption _dfo; private dtformatsetting datetimeset; zyqcultrueinfo myinfo; #endregion #region 属性 [bindable(true),browsable(false), category("appearance")] public override string text { get { return text; }
// set // { // text =value; // } } [browsable(true),category("behavior"),defaultvalue(false),description("设定是否自动适应客户端浏览器的文化区域设定。如果此属性为true,则datetimeformatshow属性的所有设置将被忽略。")] public bool autofitclientbrowser { get{ return this._autofit;} set{this._autofit = value;} }
[browsable(true),category("日期时间设置"),description("设定日期"),bindable(true)] [refreshproperties(refreshproperties.repaint)] public datetime dt { get { if(this._dt.tostring() != null) return this._dt; return datetime.now; } set { this._dt =value; if(this.datetimeformatshow != null) this.text=value.tostring(this.datetimeformatshow.formatestring,(new zyqcultrueinfo(this.datetimeformatshow.languageandcountry,true)).datetimeformat); } } [browsable(true),category("日期时间设置"),typeconverter(typeof(dtformatsettingconverter)),designerserializationvisibility(designerserializationvisibility.content),description("设定时间和日期的格式") ,refreshproperties(refreshproperties.repaint)] public dtformatsetting datetimeformatshow { get { if(this.datetimeset ==null) { this.datetimeset= new dtformatsetting(); this.datetimeset.datetimeformatchanged +=new datetimeformateeventhandler(ontextchanged); this.text=this.dt.tostring(this.datetimeset.formatestring,(new zyqcultrueinfo(this.datetimeset.languageandcountry,true)).datetimeformat); } return this.datetimeset; } set { this.datetimeset=value; this.datetimeset.datetimeformatchanged +=new datetimeformateeventhandler(ontextchanged); this.text=this.dt.tostring(value.formatestring,(new zyqcultrueinfo(value.languageandcountry,true)).datetimeformat); } } [browsable(true),category("日期时间设置"),description("设定时间和日期的格式类型。此属性只在autofitclientbrowser属性为true时,才起作用。")] public dateformatoption datetimeoption { get{return this._dfo;} set { this._dfo = value; if(this.autofitclientbrowser) if(this.site !=null) if(this.site.designmode) this.autofit(cultureinfo.currentculture.name.tolower()); } }