System.Web.UI Namespace Control Class
Returns the server control identifier generated by ASP.NET.
This property can only be used programmatically; it cannot be set when declaring the control.
The server control identifier generated by ASP.NET.
ASP.NET automatically generates a ClientID for a server control regardless of whether you have specified an ID property for it or not. This property is used to identify a control for client-side operations, such as ECMAScript functions.
Any name you assign to a server control using the ID property overrides the value of this property.
The following example retrieves the ClientID property of each control in a given Controls collection.
void Page_Load ( object src, EventArgs e ) {
// Get the list of all controls.
IEnumerator myEnumerator = Controls.GetEnumerator ( );
while ( myEnumerator.MoveNext ( ) ) {
Control myControl = ( Control ) myEnumerator.Current;
// Display the ClientID property
Response.Write ( myControl.ClientID + "<br>" );
}
}
Sub Page_Load ( sender As Object, e As EventArgs )
' Get the list of all controls.
Dim myEnumerator As IEnumerator = Controls.GetEnumerator ( )
While myEnumerator.MoveNext ( )
Dim myControl As Control = CType ( myEnumerator.Current, Control )
' Display the ClientID property.
Response.Write ( myControl.ClientID & "<br>" )
End While
End Sub |
|
C# |
VB |
Control Members NamingContainer ID INamingContainer