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 .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
13    69    2    13-05-2024
18    91    1    13-05-2024
19    81    1    13-05-2024
164    162    2    13-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.