I would like to write codes for a timer control system on WebForm.aspx. The timer control system allows users enter a specific time (such as 8pm) or a timer interval (such as 8pm - 6am) to trigger some actions. May I know how to implement this timer control system in WebForm.aspx? Thanks
You can use Timer class of System.Timers You can just drag the timer control from the toolbox(components tab) on to your webform designer For further study http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtimerstimerclasstopic.as ----- Ester wrote: ---- I would like to write codes for a timer control system on WebForm.aspx. The timer control system allows users enter a specific time (such as 8pm) or a timer interval (such as 8pm - 6am) to trigger some actions. May I know how to implement this timer control system in WebForm.aspx? Thanks
Hi Ester, Another sample on that image I did send you. Using the timer on the server side has no sence in my opinion. (This is not a production sample, the sending of the image is in my opinion to slow, however I never tested it over the net and maybe making from it a thumbnail first will than help, however I doubt it). The timer part is in Form1 I hope this helps? Cor \\\Form 1 Needs a imagebox on the page Private Sub Page_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Me.Image1.Height = New Unit(32) Me.Image1.Width = New Unit(200) Image1.Visible = True Dim scriptString As String = "<script language=JavaScript>" & _ "setclock(); function setclock(){document.images.Image1.src = " & _ "'http://localhost/WebClock/WebForm2.aspx';setTimeout('setclock()',1000)}</s cript>" Page.RegisterStartupScript("setclock", scriptString) End Sub /// \\\Form2 needs nothing Private Sub Page_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Response.Cache.SetExpires(DateTime.Now.AddTicks(500)) Dim myForeBrush As Brush = Brushes.Black Dim myFont As New Font("Times New Roman", 8, FontStyle.Regular) Dim textHeight As Single Dim bm As New Bitmap(120, 20) Dim g As Graphics = Graphics.FromImage(bm) g.Clear(Color.White) Dim textSize As SizeF = g.MeasureString("now.tostring", myFont) g.DrawString(Now.ToString, myFont, myForeBrush, _ New RectangleF(0, 0, 120, 20)) Dim ms As New IO.MemoryStream Dim arrImage() As Byte bm.Save(ms, Imaging.ImageFormat.Bmp) arrImage = ms.GetBuffer Response.BinaryWrite(arrImage) g.dispose End Sub ///
Don't see what you're looking for? Try a search.
|