位置:海鸟网 > IT > ASP.NET >

刚写好的Asp.Net时间和日期的Label控件。作为讲解Asp.net控件开发的第一部分:继承开发(1)

//==========================================================================
//名称: 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;

namespace ZYQ
{
    /// <summary>
    /// 继承自System.Globalization.CultrueInfo
    /// 这个类在以后有关使用自定义System.Globalization.CultrueInfo对象时可以使用。
    /// </summary>
    public class zyqCultrueInfo: CultureInfo
    {
        public zyqCultrueInfo(string name) : base(name)
        {
            
        }
        public zyqCultrueInfo(string name, bool useoverride) : base(name, useoverride)
        {
            //
            // TODO: Add constructor logic here
            //
        }
        /// <summary>
        /// 写重ToString()方法
        /// </summary>
        /// <returns>String:CultrueInfo对象的DisplayName</returns>
        public override string ToString()
        {
            return base.DisplayName;
        }
    
        public string GetFormatString(string qiuckFormat)
        {
            string str="";
            switch(qiuckFormat)
            {                
                case "ShortDate":
                    str=this.DateTimeFormat.ShortDatePattern;
                    break;
                case "LongDate":
                    str=this.DateTimeFormat.LongDatePattern ;
                    break;
                case "FullDate":
                    str=this.DateTimeFormat.FullDateTimePattern;
                    break;
                case "RFC1123":
                    str=this.DateTimeFormat.RFC1123Pattern;
                    break;
                case "ISO8601":
                    str=this.DateTimeFormat.SortableDateTimePattern;
                    break;
                case "UniversalSortableDateTime":
                    str=this.DateTimeFormat.UniversalSortableDateTimePattern;
                    break;
                case "ShortTime":
                    str=this.DateTimeFormat.ShortTimePattern;
                    break;
                case "LongTime":
                    str=this.DateTimeFormat.LongTimePattern;
                    break;
                case "YearMonth":
                    str=this.DateTimeFormat.YearMonthPattern;
                    break;
                default:
                    str="MM/dd/yyyy HH:mm:ss";
                    break;
                
            }
            return str;
        }
    }
}