Restore forms in XML files using ASP.NET server-side custom controls

zhaozj2021-02-17  80

Recently, the restore of a Web form concerned in the company, using ASP.NET server-side custom control restore form, where many custom controls involved in the custom controls are universal for each custom server-side control, now Points individual technologies to you, and source code cannot be provided (involving company interests).

Use the ASP.NET server to customize the control from the XML file to read the form of the form (the various controls of the form), dynamically generate various controls. Revenue several technical points,

1, read XML files

2, composite control

3, array of controls

4. Programming how the various properties of the control are controlled.

5, rendering HTML method

Server-side controls are a set of logic, which provides a user interface component that is independent of the browser. It contains methods and properties. When the page is submitted, it raises events in the server, and the server control can detect the type of client device, and then Supported tag language presents yourself. It supported markers include HTML, XML, and DHTML.

2 Read XML, this I don't say 2 server control lifecycle: 2 Composite control: Use two or more controls in the parent control) to create a composite control. The controls used in this new control are the child controls, but the generated control contains all the sub-control features, the new control presents a user interface, which can reuse the features of the existing control, including these controls, and events. The parent control can handle events thrown by sub-controls. Two things need to consider when you create a composite control. For the control to add to the control set, you must rewrite the protected CreateChildControls () method, which inherits from the control. Add each sub-control to the control tree in this method. In order to avoid naming conflicts between subcipes and other controls, you must use the InamingContainer interface. This interface needs to be used if the control has any type of data binding, or it is a template control, or it needs to send events to the child control. (Note: Sub-control processes all renders for controls, so you do not need to overwrite the render () method). 2 Control arrays: Due to the large number of similar types of controls, the most direct data structure is an array, but the .NET Framework does not support control arrays, find a method to simulate the array of analog controls: Use CollectionBase class This class provides an abstract stronger type collection base class. We can use it to implement our control arrays. An arbitrary number of controls can be included in the control array. 2 Render Server Control: Restore form elements such as lines in the form There is no corresponding server standard control, need to control the rendering of server-side controls by programming; the key classes used here are htmlTextWritter: not only can write HTML content and text, in handing HTML When the content is rendered to the request client, it also provides formatted capabilities, including marking management, adding styles to HTML content.

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

New Post(0)