PowerWEB LiveControls for ASP.NET
Tick Event
See Also  Example Send comments on this topic.
Dart.LiveControls Namespace > LiveTimer Class : Tick Event



Occurs periodically based on the LiveTimer.Interval property.

Syntax

Visual Basic (Declaration) 
<DescriptionAttribute("Event raised in the frequency specified by the Interval property.")>
<CategoryAttribute("Action")>
Public Event Tick As EventHandler
Visual Basic (Usage)Copy Code
Dim instance As LiveTimer
Dim handler As EventHandler
 
AddHandler instance.Tick, handler
C# 
[DescriptionAttribute("Event raised in the frequency specified by the Interval property.")]
[CategoryAttribute("Action")]
public event EventHandler Tick
C++/CLI 
[DescriptionAttribute("Event raised in the frequency specified by the Interval property.")]
[CategoryAttribute("Action")]
public:
event EventHandler^ Tick

Example

The following example demonstrates using a LiveTimer to periodically update a LiveControl.
Visual BasicCopy Code
'In this example, A LiveTimer periodically updates the color of a LiveLabel
'It also demonstrates using the Tag property to persist information over callbacks

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    If (Not Me.IsPostBack) Then
        'Set default values for the label
        LiveLabel1.BorderWidth = New Unit(4)
        LiveLabel1.BorderColor = Color.Red
        LiveLabel1.ForeColor = Color.Red

        'Use the Tag property to keep track of color index
        LiveLabel1.Tag = 0
        LiveLabel1.Text = "This Message will change color every few seconds"

        'Start the Timer.  It will fire a Tick event every 2 seconds
        LiveTimer1.Interval = 2000
        LiveTimer1.Start()
    End If
End Sub

Private Sub LiveTimer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles LiveTimer1.Tick
    Dim color As Color = color.Red

    'Add 1 to the color index
    Dim index As Integer = Convert.ToInt16(LiveLabel1.Tag) + 1
    LiveLabel1.Tag = index Mod 6  'mod 6 - cycle 0 to 6
    Select Case (index)
    Case 0
        color = color.Red
        Case 1
        color = color.Orange
        Case 2
        color = color.Yellow
        Case 3
        color = color.Green
        Case 4
        color = color.Blue
        Case 5
        color = color.Purple
    End Select

    'Update the LiveLabel's Color
    LiveLabel1.BorderColor = color
    LiveLabel1.ForeColor = color
End Sub
C#Copy Code
//In this example, A LiveTimer periodically updates the color of a LiveLabel
//It also demonstrates using the Tag property to persist information over callbacks

private void Page_Load(object sender, System.EventArgs e)
{
	if (!this.IsPostBack)
	{
		//Set default values for the label
		LiveLabel1.BorderWidth = 4;
		LiveLabel1.BorderColor = Color.Red;
		LiveLabel1.ForeColor = Color.Red;

		//Use the Tag property to keep track of color index
		LiveLabel1.Tag = 0;
		LiveLabel1.Text = "This Message will change colors every few seconds!";

		//Start the Timer.  It will fire a Tick event every 2 seconds
		LiveTimer1.Interval = 2000;
		LiveTimer1.Start();
	}
}

private void LiveTimer1_Tick(object sender, System.EventArgs e)
{
	Color color = Color.Red;

	//Add 1 to the color index
	int index = Convert.ToInt16(LiveLabel1.Tag) + 1;
	LiveLabel1.Tag = index%6;  //mod 6 - cycle 0 to 6
	switch (index)
	{
		case 0:
			color = Color.Red;
			break;
		case 1:
			color = Color.Orange;
			break;
		case 2:
			color = Color.Yellow;
			break;
		case 3:
			color = Color.Green;
			break;
		case 4:
			color = Color.Blue;
			break;
		case 5:
			color = Color.Purple;
			break;
	}

	//Update the LiveLabel's Color
	LiveLabel1.BorderColor = color;
	LiveLabel1.ForeColor = color;
}

Remarks

The Tick event fires when the interval since the last Tick event has elapsed.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 4.0.2
© 2012 Dart Communications. All Rights Reserved.