System.Web.UI Namespace Control Class
Occurs when the control is initialized, the first step in the page lifecycle.
[ VB ]
Public Event Init As EventHandler
[ C# ]
public event EventHandler Init;
[ C++ ]
public: __event EventHandler* Init;
In [ JScript ], you can handle the events defined by a class, but you cannot define your own.
The event handler receives an EventArgs containing data related to the Init event.
Server controls should perform any initialization steps that are required to
create and set up an instance. You cannot use view-state information within this
event; it is not populated yet. You should not access another server control
during this event, regardless of whether it is a child or parent to this
control. Other server controls are not certain to be created and ready for
access.
The following example demonstrates a handler for the Init event.
void Page_Init ( object sender,EventArgs e ) {
// add an 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 );
}
Sub Page_Init ( sender As Object, e As EventArgs )
' add an event Handler for 'Init'.
AddHandler myControl.Init, AddressOf Control_Init
End Sub
Sub Control_Init ( sender As Object, e As EventArgs )
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 ) )
End Sub |
|
C# |
VB |
Control Members BaseControlBuilder