PowerWEB LiveControls for ASP.NET
Interval Property
See Also  Send comments on this topic.
Dart.LiveControls Namespace > LiveTimer Class : Interval Property



Gets or sets the time interval (in milliseconds) for which the Timer.Tick event is raised.

Syntax

Visual Basic (Declaration) 
<DescriptionAttribute("Determines the amount of time between Tick events")>
<DefaultValueAttribute()>
<CategoryAttribute("Behavior")>
Public Property Interval As Integer
Visual Basic (Usage)Copy Code
Dim instance As LiveTimer
Dim value As Integer
 
instance.Interval = value
 
value = instance.Interval
C# 
[DescriptionAttribute("Determines the amount of time between Tick events")]
[DefaultValueAttribute()]
[CategoryAttribute("Behavior")]
public int Interval {get; set;}
C++/CLI 
[DescriptionAttribute("Determines the amount of time between Tick events")]
[DefaultValueAttribute()]
[CategoryAttribute("Behavior")]
public:
property int Interval {
   int get();
   void set (    int value);
}

Property Value

The time interval between LiveTimer.Tick events for the LiveTimer control. The default is 5000.

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

Use this property to specify the time interval (in milliseconds) for which the Timer.Tick event is raised.

This property does not have any effect unless the LiveTimer is enabled, either by setting Enabled to true, or by calling LiveTimer.Start

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

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