2009-07-13 135 views
3

如何在文本框中顯示選定的日曆值?我想在asp.net或C#中的答案。顯示日曆值

+0

你使用什麼日曆? – Amadeus45 2009-07-13 05:48:40

+0

在asp.net工具箱中可用的壓延機 – MAC 2009-07-13 05:49:17

回答

6

對於的WinForms(我用DateTimePicker)可以處理ValueChanged事件......

private void dateTimePicker1_ValueChanged(object sender, EventArgs e) 
{ 
    textBox1.Text = dateTimePicker1.Text; 
} 

對於ASP.NET控件(我用Calendar控制)您可以處理SelectionChanged事件...

[Markup] 
<asp:Calendar ID="Calendar1" runat="server" 
    onselectionchanged="Calendar1_SelectionChanged"></asp:Calendar> 

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 



[CodeBehind] 
protected void Calendar1_SelectionChanged(object sender, EventArgs e) 
{ 
    TextBox1.Text = Calendar1.SelectedDate.ToShortDateString(); 
} 

希望它有幫助:)