ラベルを更新し、現時点で最後に更新されたものに変更するタイマーメソッドを処理するコードがいくつかあります。
Protected Sub specialNotesTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles specialNotesTimer.Tick
Label1.Text = "Panel refreshed at: " + DateTime.Now.ToLongTimeString()
End Sub
ただし、カチカチ音をたてると、ボタンを押してもページ上の他のコントロールを見つけることができません。画像ボタンまたはその他の動的に作成されたコントロールがありません。ページで発生したコントロールを見つけてコントロールを返す関数があるので、何をすべきかを判断できます
Public Shared Function GetPostBackControl(ByVal thePage As Page) As Control
Dim myControl As Control = Nothing
Dim ctrlName As String = thePage.Request.Params.Get("__EVENTTARGET")
If ((ctrlName IsNot Nothing) And (ctrlName <> String.Empty)) Then
myControl = thePage.FindControl(ctrlName)
Else
For Each Item As String In thePage.Request.Form
Dim c As Control = thePage.FindControl(Item)
If (TypeOf (c) Is System.Web.UI.WebControls.Button) Then
myControl = c
End If
Next
End If
Return myControl
End Function
これは timer.tick の前では機能しますが、後では機能しません。コントロールは thePage.Request.Form の項目としてリストされず、コントロールがそこにあることがわかっている場合は null 例外がスローされます。