若樣版欄位內的Calendar被點選後,希望把值帶給另一個textbox樣版欄位,
若網頁與程式碼沒有分離,當Calendar被點選後,會發生的事情如下
Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim tb As TextBox = Me.FormView1.FindControl("HireDateTextBox")
tb.Text = sender.SelectedDate.ToString()
End Sub
如果網頁與程式碼分離,當Calendar被點選後,會發生的事情如下
Protected Sub Calendar2_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim SenderCalendar As Calendar = CType(sender, Calendar)
Dim tb As TextBox = Me.FormView1.FindControl("HireDateTextBox")
tb.Text = SenderCalendar.SelectedDate.ToString()
End Sub
Calendar本身也得作型別轉換
沒有留言:
張貼留言