S
Sir Bill
I can not seem to get a system timer to work for me. Here is the code both
the aspx and aspx.vb file. The textbox displays "Timer Started" and never
anything else. What am I missing?
<%@ Page Language="VB" Debug="true" AutoEventWireup="false"
CodeFile="test.aspx.vb" Inherits="test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server">This is a text
box</asp:TextBox>
</div>
</form>
</body>
</html>
And the following codebehind file:
Imports System.Web.UI.WebControls
Partial Class test
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not IsPostBack Then
CreateTimer()
Dim myTxt As WebControls.TextBox
myTxt = Form.FindControl("TextBox1")
myTxt.Text = "Timer Started"
End If
End Sub
Private Sub CreateTimer()
Dim Timer1 As New System.Timers.Timer
Timer1.Interval = 5000
Timer1.Enabled = True
AddHandler Timer1.Elapsed, New
System.Timers.ElapsedEventHandler(AddressOf Me.Timer1_elapsed)
End Sub
Private Sub Timer1_elapsed(ByVal sender As System.Object, ByVal e As
System.Timers.ElapsedEventArgs)
Dim myText As WebControls.TextBox
myText = Form.FindControl("textbox1")
myText.Text = "Timer Popped " & Today.TimeOfDay.ToString
End Sub
End Class
the aspx and aspx.vb file. The textbox displays "Timer Started" and never
anything else. What am I missing?
<%@ Page Language="VB" Debug="true" AutoEventWireup="false"
CodeFile="test.aspx.vb" Inherits="test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server">This is a text
box</asp:TextBox>
</div>
</form>
</body>
</html>
And the following codebehind file:
Imports System.Web.UI.WebControls
Partial Class test
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not IsPostBack Then
CreateTimer()
Dim myTxt As WebControls.TextBox
myTxt = Form.FindControl("TextBox1")
myTxt.Text = "Timer Started"
End If
End Sub
Private Sub CreateTimer()
Dim Timer1 As New System.Timers.Timer
Timer1.Interval = 5000
Timer1.Enabled = True
AddHandler Timer1.Elapsed, New
System.Timers.ElapsedEventHandler(AddressOf Me.Timer1_elapsed)
End Sub
Private Sub Timer1_elapsed(ByVal sender As System.Object, ByVal e As
System.Timers.ElapsedEventArgs)
Dim myText As WebControls.TextBox
myText = Form.FindControl("textbox1")
myText.Text = "Timer Popped " & Today.TimeOfDay.ToString
End Sub
End Class