English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I got a text box named monitor and the timer should read from a sesion.txt file into the textbox..but i cannot see it....what am i mising?

Dim path As String = Server.MapPath("~/app_data/sesion.txt")
Dim t As New System.Timers.Timer(8000)

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AddHandler t.Elapsed, AddressOf TimerFired
t.Enabled = True
End Sub
Public Sub TimerFired(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
If IsPostBack Then
monitor.Text = My.Computer.FileSystem.ReadAllText(path)
End If
End Sub

2007-01-17 11:28:53 · 2 answers · asked by kain_odeh 2 in Computers & Internet Programming & Design

is there any way I can do a timer in vb
if not what is the code in javascript and were should i put it
...thanks for the help

2007-01-17 11:52:32 · update #1

2 answers

Essentially what you are doing is when Page_Load executes, you are starting a timer, but when the page is done executing the timer is trashed along with all the other objects on the page. Which should be long before the 8000 milliseconds lapse, unless you are doing some serious processing elsewhere in the page.

You need to write a client-side timer in JavaScript that communicates with your VB.NET server-side code to accomplish what it seems like you're talking about.

2007-01-17 11:36:49 · answer #1 · answered by Rex M 6 · 1 0

The javascript you could use would look something like this:


function updateTextbox
{
//Here you could make an ajax call to the server to get the sesion.txt file to update your textbox.
}

self.setTimeout('updateTextbox ()', 8000)



Make sure you remove the space between "updateTextbox" and "()". For some reason it was reformatting that combination of code with "...".

2007-01-17 22:27:36 · answer #2 · answered by hojack 1 · 0 1

fedest.com, questions and answers