日历控件的两个问题
代码:
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/// <summary>
/// </summary>
public class Calendar : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.Calendar Calendar1;
protected System.Web.UI.WebControls.Panel pnlCalendar;
protected System.Web.UI.WebControls.TextBox TextBoxDate;
protected System.Web.UI.HtmlControls.HtmlInputButton Button1;
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
this.TextBoxDate.Text = System.DateTime.Now.ToShortDateString();
this.pnlCalendar.Attributes.Add( "style ", "DISPLAY: none; POSITION: absolute ");
}
else
{
string id = Page.Request.Form[ "__EVENTTARGET "].Substring(0,Page.Request.Form[ "__EVENTTARGET "].IndexOf( ": "));
if (id != this.ID)
{
this.pnlCalendar.Attributes.Add( "style ", "DISPLAY: none; POSITION: absolute ");
}
else
{
this.pnlCalendar.Attributes.Add( "style ", "POSITION: absolute ");
}
}
Page.RegisterClientScriptBlock( "Script_Panel " + this.ID,
" <script> function On "+this.ID+ "Click() { if( "+this.ID+
"_pnlCalendar.style.display == \ "none\ ") "+this.ID+
"_pnlCalendar.style.display = \ "\ "; else "+this.ID+
"_pnlCalendar.style.display = \ "none\ "; } </script> ");
this.Button1.Attributes.Add( "OnClick ", "On "+this.ID+ "Click() ");
InitializeComponente();
// 在這裡放置使用者程式碼以初始化網頁
}
#region Web Form 設計工具產生的程式碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 此為 ASP.NET Web Form 設計工具所需的呼叫。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 此為設計工具支援所必須的方法 - 請勿使用程式碼編輯器修改
/// 這個方法的內容。
/// </summary>
private void InitializeComponent()
{
this.Calendar1.SelectionChanged += new System.EventHandler(this.Calendar1_SelectionChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
//
// override protected void OnInit(EventArgs e)
// {
// //
// //
// InitializeComponent();
// base.OnInit(e);
// }
private void InitializeComponente()
{
this.Calendar1.SelectionChanged += new System.EventHandler(this.Calendar1_SelectionChanged);
this.Load += new System.EventHandler(this.Page_Load);