TAILIEUCHUNG - Professional ASP.NET 1.0 Special Edition- P33

Professional Special Edition- P33:Those of us who are Microsoft developers can't help but notice that .NET has received a fair amount of visibility over the last year or so. This is quite surprising considering that for most of this period, .NET has been in its early infancy and beta versions. I can't remember any unreleased product that has caused this much interest among developers. And that's really an important point, because ignoring all the hype and press, .NET really is a product for developers, providing a great foundation for building all types of applications | Allows expando attributes . attributes that are not pre-defined properties of the control to be specified in a server-control declaration. Expando attributes are not interpreted and are written directly to the output HTML stream. By default the Control class throws an exception if an attribute is not a property of the server control. Provides consistency with the standard web controls since they derive from the WebControl class. Persists the style object and any settings state during postbacks using view state. In the control example earlier when we used the style object any style changes made in event handlers or in other code would not have been remembered after a postback since the state of the style object was not being round tripped using viewstate. For our control to remember any style changes because it is derived from Control we d need to implement custom statement management by overriding the LoadViewState and SaveViewState methods. Viewstate is discussed later in the chapter. The WebControl class is designed to either assist with the rendering of a control or take complete control of the rendering. For a simple control such as our label the WebControl class can be used to replace most of the code we have written. To make use of the WebControl class we have to make the following changes to our code Derive from the WebControl class rather than Control class. Declare a public constructor that calls the base constructor specifying which HTML element to render. Override the RenderContents method to emit the content we want within our h1 element. The WebControl class takes responsibility for rendering the attributes and the begin end-tags so we remove the Render method. Remove all of the style properties we implemented earlier since the WebControl will automatically have implemented them for us. After making these changes our C control code looks like this using System using using using namespace .

1    4    0    09-08-2020
27    5    0    09-08-2020
5    5    0    09-08-2020
1    14    0    09-08-2020
42    4    0    09-08-2020
19    16    0
182    15    0
138    6    0
3    7    0
142    12    0