必须填写至少10个字的日志
nnhy authored at 2012-07-27 18:48:21
2.12 KiB
X
using System;
using System.Collections.Generic;
using System.Text;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.ComponentModel;
using System.IO;
using System.Drawing;

// ÌرðҪעÒ⣬ÕâÀïµÃ¼ÓÉÏĬÈÏÃüÃû¿Õ¼äºÍĿ¼Ãû£¬ÒòΪvs2005±àÒëµÄʱºò»á¸øjsÎļþ¼ÓÉÏÕâЩ¶«¶«µÄ
[assembly: WebResource("XControl.TextBox.DateBox.SelectDate.js", "application/x-javascript")]

namespace XControl
{
    /// <summary>ÈÕÆÚÑ¡Ôñ¿Ø¼þ</summary>
    [Description("ÈÕÆÚÑ¡Ôñ¿Ø¼þ")]
    [ToolboxData("<{0}:DateBox runat=server></{0}:DateBox>")]
    [ToolboxBitmap(typeof(TextBox))]
    public class DateBox : TextBox
    {
        /// <summary>³õʼ»¯Ñ¡Ôñ¿òµÄÑùʽ¡£</summary>
        public DateBox()
            : base()
        {
            //this.BackColor = Color.FromArgb(0xff, 0xe0, 0xc0);
            this.ToolTip = "µã»÷¼´¿ÉÑ¡ÔñÈÕÆÚ";
            BorderWidth = Unit.Pixel(0);
            BorderColor = Color.Olive;
            BorderStyle = BorderStyle.Dotted;
            Font.Size = FontUnit.Point(10);
            Width = Unit.Pixel(118);
            if (String.IsNullOrEmpty(Attributes["style"])) this.Attributes.Add("style", "border-bottom-width:1px;");
        }

        /// <summary>ÒÑÖØÔØ¡£</summary>
        /// <param name="e"></param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            // µ¯³öPopup
            this.Attributes.Add("onclick", "SelectDate(this);");
            this.Page.ClientScript.RegisterClientScriptResource(this.GetType(), "XControl.TextBox.DateBox.SelectDate.js");
        }

        /// <summary>µ±Ç°Öµ</summary>
        [Category(" רÓÃÊôÐÔ"), DefaultValue(0), Description("µ±Ç°Öµ")]
        public DateTime Value
        {
            get
            {
                if (String.IsNullOrEmpty(Text)) return DateTime.MinValue;
                DateTime k;
                if (!DateTime.TryParse(Text, out k)) return DateTime.MinValue;
                return k;
            }
            set
            {
                Text = value.ToString("yyyy-MM-dd HH:mm:ss");
            }
        }
    }
}