Development of control

xiaoxiao2021-03-05  26

The control can be developed lies in its reusability.

ASP.NET can create a replicated visual control displayed in HTML or other tag language.

Two controls were created by learning the CC # .NET programming classics.

One is a control with attributes, one is a control of the method.

(Traditional Significance) The control for development actually has two: Custom Control and User Control. Custom Control is longitudinally, inheritance and expansion of the system itself, in the form of a DLL file in the program, User Control is horizontally, is a combination of the system itself, in the system .ascx as a suffix name. These two control functions can provide developers with a reuseful visual UI component, compared to the former with greater flexibility, while developing is more complicated, while the latter is easy to develop, but the reusability is compared difference. Generally speaking, users will be developed with user control, and only when they are overwhelmed, use Custom Control. In fact, the user's own development of Custom Control is not a very difficult thing, just need to define a class directly or indirectly derived from the Control and rewrite its render method, System.Web.ui.Control and System.Web .Ui.webControls.webControl two classes are the base class of the server control. The Control class defines the properties, methods, and events of all server controls. These include control controls to perform a life cycle method and event, and attributes such as ID, UNIQUEID, PARENT, ViewState, and Controls (sub-control sets). Control does not have any user interface (UI) specific features. If the created control does not provide a UI, or a control of other programs presenting its own UI, derive from Control. The WebControl class is derived from Control and provides additional properties and methods for the UI feature. These properties include Forecolor, Backcolor, Font, BorderStyle, Height, and Width. WebControl is the base class of the web server control series in ASP.NET. If the control presents a UI, derive from WebControl. You can rewrite the properties, methods, and events inherited from the base class, and you can add new properties, methods, and events to your custom control, as mentioned above, we use the rewrite render method to implement the output of the HTML code. The render method uses the System.Web.ui.htmlTextWriter type parameter. The control is sent to the client's HTML as a string parameter to the Write method of the HTMLTextWriter.

The web control is a very special class, which can have no constructor, or there can be. The web control itself is a class, which can only be a class. Of course, there can be other classes to help it implement some features together.

A description of the WEB control is running,

1. Initialization: Initialization Incoming Init Events (OnInit Method) during the incoming Web request lifecycle;

2, load the view status: Automatically populate the ViewState property of the control, process the loadViewState method;

3. Process the return data: Process the incoming form data and update the attribute accordingly. Call the LoadPostData method (if you have implemented ipostbackdatahandler;

4, loading: Perform all requests, excitation the LOAD events (ONLOAD method);

5. Send a return change notification: Change the change event to respond to the status change between the current and previous rapids. Handle the RaisePostDataChangeDevent method (IPOSTBACKDATAHANDAL) (if you have implemented iPostBackDataHandler); 6, process the retrace event: Processing the retrace event, and triggeting the corresponding event on the server. Inspire the RaisePostBackevent method (if you have implemented ipostbackeventhandler;

7. Pre-presentation: Do any update before presenting the output. Handling Prerender Events;

8, save the status: Automatically keep the control value of the control to the string object. This string object is sent to the client and sent back as a hidden variable. Handling SaveViewState method;

9, presentation: Generate the output presentation to the client. Handling Render or CreateChildControls method;

10. Disposal: Perform all final cleaning operations before destruction control. Handling Dispose method;

11, Uninstall: All final cleaning operations before the destruction control is performed. Controls are typically cleared in Dispose without processing this event. Inspire UNLOAD events.

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

New Post(0)