First, custom control presence
1. Render method controls the output 2 of the custom control 2. Call addAttribute, addStyAttribute, etc. Specify the properties and characteristics of the next element, call the renderbegintag output HTML Start Tag 4, call the Writer method to inform the HTMLTextWriter output specified content to HTML stream Medium 5, call renderendTag Output HTML End Marker
Second, the event of custom controls
Declare events To declare events within the category, you must first declare the delegate type (if you have not declare). Public Delegate Void ChangeDeventHandler (Object Sender, Eventargs E); a set of parameters that pass to the method of processing the event. Multiple events can share the same entrust type, so it is only necessary when any suitable commission type has not yet declare.
step. Next, declare the event itself. Public Event ChangeDeventHandler Changed; Declare the event is similar to the field of the declaration, just the keyword Event, in front of the event declaration, behind the modifier. Events are usually declared as public events, but allow any
Access the modifier. After the event class declares the event, it can process the event as a field indicated by the delegated type. If no client will entrust it with the event, this field will
Empty; otherwise the field reference should be invoked when calling the event. Therefore, when you call an event, you will usually check if it is empty, then call the event. if (Changed! = NULL) Changed (this, e); calling events can only be done from within the class that declares the event. Look with the event hook from the category of statement, the event is like a field, but access to this field is very limited. Only the following operations: written new delegates on this field. Remove the delegate from the field (which may be a composite field). Use the = and - = operator to complete this. To start receiving event calls, customer code first creates a delegate of event types, which should be called from event calls. Then it uses =
Write the commission to any other delegation that may be connected. // Add "listchanged" to the change Event on "list": list.changed = new changeEventHandler (ListChanged); After the customer code completes the receiving event call, it will use the operator - = from the event to the delegate. // DETACH The Event and delete the list: list.changed - = new changedEventHandler (ListChanged);