//========================================================================== //名稱: 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()); } }