Why is the user control to open an attribute, etc.

xiaoxiao2021-03-06  106

The level protection level of all controls in the control layout, they are unacceptable for external calories, to solve this problem, need to define a public property for each control to be disclosed (it is best to read, but The caller can set any of their properties), make sure these properties have different names with the IDs they represent.

User Control Definition Method: You only need to define a public approach.

User Control Open Event: Need to answer a question is whether you want to return event-specific data. Pass or do not transfer data affects the signature of the event handler for the control and its clients. If you don't need to pass data, you can use the standard event handler EventHandler. In this case, a public event called datechanged is this:

Public evenet athandler datechan

There is also a need for a help function to call user-defined event handler inside the space. Generally adopted the following manner

Protected Virtural Void OnDateChanged (Eventargs E) {

IF (datechanged! = null) {

Datechanged (this, e)}

}

When a custom data is involved, it is necessary to define a special data structure that extends class Eventargs, and a new delegate type using this data structure (DELEGATE ---- a secure function pointer) final control public control .

If you raise multiple events, you can optimize their storage by using event properties instead of event fields. For the event field, the compiler generates a field for each instance of the event, which is unacceptable for events that are not commonly used. Event properties include event declarations accompanying event accessor:

Public Event DatechangerHandler DateChanged {add {events.addhandler (EventdateChanged, value);} remove {events.removehandler (EventDateChanged, Value);}}

All User Controls ----- ASP.NET elements referenced by all ASCX files belong to ASP namespace

转载请注明原文地址:https://www.9cbs.com/read-122933.html

New Post(0)