Control.ID Property
Assembly: System.Web (in system.web.dll)
Setting this property on a server control provides you with programmatic access to the server control's properties, events, and methods. This property can be set by Web developers by declaring an ID attribute in the opening tag of an ASP.NET server control.
If this property is not specified for a server control, either declaratively or programmatically, you can obtain a reference to the control through its parent control's Controls property.
Note |
|---|
| Including spaces in this property will cause an ASP.NET page parser error. |
void Page_Init(object sender,EventArgs e) { // Add a event Handler for 'Init'. myControl.Init += new System.EventHandler(Control_Init); } void Control_Init(object sender,EventArgs e) { Response.Write("The ID of the object initially : " + myControl.ID); // Change the ID property. myControl.ID="TestControl"; Response.Write("<br>The changed ID : " + myControl.ID); }
void Page_Init(Object sender,EventArgs e)
{
// Add a event Handler for 'Init'.
myControl.add_Init(new System.EventHandler(Control_Init));
} //Page_Init
void Control_Init(Object sender,EventArgs e)
{
get_Response().Write("The ID of the object initially : "
+ myControl.get_ID());
// Change the ID property.
myControl.set_ID("TestControl");
get_Response().Write("<br>The changed ID : " + myControl.get_ID());
} //Control_Init
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Note