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



Gets or sets a convertible object that contains data about the control.

Syntax

Visual Basic (Declaration) 
<BrowsableAttribute(False)>
Public Property Tag As Object
Visual Basic (Usage)Copy Code
Dim instance As LiveTableCell
Dim value As Object
 
instance.Tag = value
 
value = instance.Tag
C# 
[BrowsableAttribute(false)]
public object Tag {get; set;}
C++/CLI 
[BrowsableAttribute(false)]
public:
property Object^ Tag {
   Object^ get();
   void set (    Object^ value);
}

Property Value

An object that implements the IConvertible interface and contains data about the PowerWEB control. The default is a null reference (Nothing in Visual Basic).

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

Any type that implements IConvertible can be assigned to this property. If the Tag property is set through the Windows Forms designer, only text can be assigned.

Data contained within the Tag property persists across callbacks. A common use for the Tag property is to store data that is closely associated with the control.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

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