I. Add events directly
method:
Write the following code in the page_load event (UcequipmentQuery1 is the user control):
DropDownList DDL = (DropDownList) UcequipmentQuery1.FindControl ("DropdownList1"); ddl.selectedIndexchanged = New EventHandler (DDL_Selected IndexChanged);
Write an event handler in the page:
Private void DDL_Selected Indied Indexchanged (Object Sender, Eventargs E) {
//deal with
}
Ii. You can use Event Bubble to implement
method:
a. Call the RaisebubbleEvent method in the event of the user control DropDownList, such as:
Private void DropdownList1_selectedIndexchanged (Object Sender, System.EventArgs E) {this.raisebubbleEvent (Sender, E);
b. Overload the onbubbleevent method in the page code, such as:
Protected Override Bool OnbubbleEvent (Object Source, System.EventArgs Arg) {IF (Source Is DropdownList) {
// Handle Return True;} Return Base.OnbubbleEvent (Source, Arg);
Note: This method does not apply to a number of user controls in a page.