Property Value

The fully-qualified identifier for the server control.

Remarks

This property differs from the ID property, in that the UniqueID property includes the identifier for the server control's naming container. This identifier is generated automatically when a page request is processed.

This property is particularly important in differentiating server controls contained within a data binding server control that repeats. The repeating control, which are Repeater, DataList, and DataGrid Web server controls (or any custom server controls that you create that include repeating functionality when data bound), serves as the naming container for its child controls. This means that it creates a unique namespace for its child controls so that their ID property values do not conflict.

For example, if you include an ASP.NET Label Web server control in a Repeater server control, and assign the Label control an ID property value of MyLabel, and the Repeater an ID of MyRepeater. If you bind data to the Repeater to an ArrayList object with three entries, the resulting UniqueID properties for each instance of the Label server controls are MyRepeater:ctl0:MyLabel, MyRepeater:Ctl1:MyLabel, and MyRepeater:Ctl2:MyLabel.

Example

[Visual Basic, C#] The following example creates an ArrayList object and populates it with three text strings, then binds the data in the ArrayList to a Repeater Web server control when the page is loaded. When a user clicks the button associated with the Button1_Click method, the UniqueID property is obtained for each child control of the Repeater that was added when the DataBind method was called.