Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/10/2010, 05:50
quifransa
 
Fecha de Ingreso: diciembre-2008
Mensajes: 13
Antigüedad: 15 años, 4 meses
Puntos: 0
Funcionamiento de timer en aspx .net

Hola estoy trabajando con Visual Web Developer 2005 y estoy implementando un cronómetro. He instalado el toolkit de Ajax y he arrastrado los componentes a mi página. He arrastrado un timer, un label y tres botones. Hasta aquí todo bien aunque cuando le digo al Label1.Refresh() me sale el error: Refresh no es miembro de 'System.Web.UI.WebControls.Label'. Alguien sabría decirme si me falta instanciar alguna cosa o porqué me sale este error!!

El codigo que he implemetntado es:

<%@ Page Language="VB" %>
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="utf-8" %>
<%@ import Namespace = "System.data" %>
<%@ import Namespace = "System.data.odbc" %>
<%@ Import Namespace = "System.Web.Configuration" %>



<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Private hora As Integer = 0
Private minuto As Integer = 0
Private segundo As Integer = 0
Private milisegundo As Integer = 0


Protected Sub mostrarTiempo()

Label1.Text = hora.ToString.PadLeft(2, "0") & ":"

Label1.Text &= minuto.ToString.PadLeft(2, "0") & ":"

Label1.Text &= segundo.ToString.PadLeft(2, "0") & ":"

Label1.Text &= milisegundo.ToString.PadLeft(1, "0")

Label1.Refresh()

End Sub

Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
milisegundo += 1
If milisegundo = 9 Then

milisegundo = 0

segundo += 1

If segundo = 59 Then

segundo = 0

minuto += 1

If minuto = 59 Then

minuto = 0

hora += 1

End If
End If
End If
mostrarTiempo()
End Sub

Protected Sub iniciar_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Timer1.Enabled = True
End Sub

Protected Sub pausa_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Timer1.Enabled = False
End Sub

Protected Sub zero_Click(ByVal sender As Object, ByVal e As System.EventArgs)
hora = 0
minuto = 0
segundo = 0
milisegundo = 0


mostrarTiempo()
End Sub



</script>


MUchas gracias.