答案://==========================================================================
//名称: ZYQ.WebControls.Cultural.DateTimePick.DateTimePickLabel
// Asp.Net服务控件
//版本: 1.0.0.0
//作者: 张宇庆
//日期: 2003.2.12
//Email: raxzhang@sina.com
//说明: 本控件及源代码只是为《计算机世界》开发者俱乐部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;  
上一个:刚写好的Asp.Net时间和日期的Label控件。作为讲解Asp.net控件开发的第一部分:继承开发(4)
下一个:·.NET中的动态生成图像组件