1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace DymWebForm.Aspx
- {
- internal class DateTimeTextBox: TextBox
- {
- protected override void OnPreRender(EventArgs e)
- {
- base.OnPreRender(e);
- this.MaxLength = this.IsContainTime ? 19 : 10;
- base.Attributes.Add("size", this.MaxLength.ToString());
- ScriptManager.RegisterClientScriptResource(this, this.GetType(), this.GetType().Namespace + ".Resources.Calendar.js");
- }
- protected override void Render(HtmlTextWriter writer)
- {
- base.Render(writer);
- string iconUrl = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), this.GetType().Namespace + ".Resources.Calendar.Icon.Norm.bmp");
- string iconUrl2 = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), this.GetType().Namespace + ".Resources.Calendar.Icon.Hove.bmp");
- writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
- writer.AddAttribute(HtmlTextWriterAttribute.Src, iconUrl);
- writer.AddAttribute(HtmlTextWriterAttribute.Onclick, string.Format("new Calendar(null, null, 0).show(document.getElementById('{0}'));", this.ClientID));
- writer.AddAttribute("onmouseover", string.Format("this.src='{0}';", iconUrl2));
- writer.AddAttribute("onmouseout", string.Format("this.src='{0}';", iconUrl));
- writer.RenderBeginTag(HtmlTextWriterTag.Img);
- writer.RenderEndTag();
- }
- public bool IsContainTime
- {
- get
- {
- if (this.ViewState[this.UniqueID + ":IsContainTime"] == null)
- {
- return true; //the default value
- }
- return (bool)this.ViewState[this.UniqueID + ":IsContainTime"];
- }
- set
- {
- this.ViewState[this.UniqueID + ":IsContainTime"] = value;
- }
- }
- }
- }
|