2017-06-26 48 views
-1

我可以看到網頁上的日期人口。但是,它沒有出現在TextBox中。我需要選擇的日曆日期顯示在TextBox上。如何使用Calendar控件的日期填充TextBox控件?

下面是我的Default.aspx代碼:

<%@ Page Language="VB" %> 

    <script runat="server"> 
     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 
      TextBox1.Focus() 
     End Sub 
     Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) 
      Response.Write("You selected: " & 
      Calendar1.SelectedDate.ToShortDateString()) 
     End Sub 
    </script> 

    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head id="Head1" runat="server"> 
     <title>Using the Calendar Control</title> 
    </head> 
    <body> 
     <form id="form1" runat="server"> 
     <div> 
      <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
     <asp:Calendar ID="Calendar1" runat="server" 
      OnSelectionChanged="Calendar1_SelectionChanged"> 
     </asp:Calendar> 
     </div> 
     </form> 
    </body> 
    </html> 
+0

去掉標籤;降噪。 – Bugs

回答

0

更改行:

Response.Write("You selected: " & Calendar1.SelectedDate.ToShortDateString()) 

到:

TextBox1.Text = Calendar1.SelectedDate.ToShortDateString() 
從標題
+0

Racil Hilan,謝謝你的指導。它解決了這個問題。 –