see an example here:Populating Form Inputs Using the Calendar Control
http://aspnet.4guysfromrolla.com/articles/030202-1.aspx

解决方案 »

  1.   

    <asp:Button id="Button2" style="Z-INDEX: 102; LEFT: 305px; POSITION: absolute; TOP: 255px" runat="server" Text="+" Width="20px"></asp:Button>
    <asp:TextBox id="TextBox1" style="Z-INDEX: 103; LEFT: 141px; POSITION: absolute; TOP: 256px" runat="server"></asp:TextBox>
    <asp:Panel id="Panel1" style="Z-INDEX: 104; LEFT: 50px; POSITION: absolute; TOP: 291px" runat="server" Visible="False">
    <asp:Calendar id="Calendar1" runat="server"></asp:Calendar>
    </asp:Panel>**************************************************************************
    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    //Button1.Attributes["onclick"] = "<script language='JavaScript'>alert('hi');"+"</script>";

    TextBox1.Text = DateTime.Now.ToShortDateString();
    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Button2.Click += new System.EventHandler(this.Button2_Click);
    this.Calendar1.SelectionChanged += new System.EventHandler(this.Calendar1_SelectionChanged);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void Button1_Click(object sender, System.EventArgs e)
    {
    Page.Response.Write("aaaaaaaaaaaa");
    } private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
    {
    TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
    Panel1.Visible = false;
    } private void Button2_Click(object sender, System.EventArgs e)
    {
    Panel1.Visible = true;
    }
      

  2.   

    在页面上设置一个Calendar,Calendar.Visible = false,private void Button_recvdate_Click(object sender, System.EventArgs e)
    {
    Calendarnew1.Visible = true;
    TextBoxdate.Text = "recv";
            } private void Calendarnew1_SelectionChanged(object sender, System.EventArgs e)
    {
    if (TextBoxdate.Text.Equals("recv"))
    TextBoxrecvdate.Text = Calendarnew1.SelectedDate.ToShortDateString();
    if (TextBoxdate.Text.Equals("prep"))
    TextBoxprepdate.Text = Calendarnew1.SelectedDate.ToShortDateString();

    Calendarnew1.Visible = false;
    } private void Button_prepdate_Click(object sender, System.EventArgs e)
    {
    Calendarnew1.Visible = true;
    TextBoxdate.Text = "prep";
    }