This book focuses on the combination of theory and practice, and basically has corresponding example applications for each ASP.NET control development technical knowledge point. In terms of chapter classification, it is classified according to the category of technical points. The content is relatively comprehensive. Each control development technical point is explained in detail. This book can also be used as a search manual.
Table of contents: Chapter 1 Server Control Overview and Development Environment Deployment 1 1.1 Custom server control 1 1.2 The role of server controls in the software development process 1 1.3 Improve yourself in control development 2 1.4 Introduction to inheritable control base classes 2 1.5 Running a simple control 7 1.5.1 Develop a simple control 7 1.5.2 Deployment and operation 11 1.6 Control life cycle 12 1.6.1 Overview 12 1.6.2 Use code to track the control life cycle process 14 1.7 Summary of this chapter 17 Chapter 2 Debugging Technology in Server Control Development 18 2.1 Preset code example 18 2.2 Debug page server code 19 2.3 Debugging of server controls 20 2.3.1 Debugging method in running mode 20 2.3.2 Debugging method in design mode 20 2.4 JavaScript script debugging method 22 2.4.1 Debugging JavaScript scripts in pages (Method 1) 22 2.4.2 Debugging JavaScript scripts in pages (Method 2) 23 2.4.3 Debugging non-embedded JavaScript script files 23 2.4.4 Debugging embedded JavaScript script resource files 24 2.4.5 Tips for efficient debugging 24 2.5 Ajax Library supports JavaScript debugging 26 2.6 Summary of this chapter 26 Chapter 3 Developing Server Controls from Scratch 27 3.1 Selecting a base class 27 3.2 Control presentation order 28 3.3 Several ways for Render to present controls 30 3.3.1 Use HTMLTextWriter class to output 30 3.3.2 Directly output HTML tags 32 3.3.3 Using RenderControl of server control Method 33 3.4 AddAttributesToRender method 34 3.5 CreateChildControls method 35 3.6 INamingContainer interface 36 3.7 Implementing composite controls 38 3.7.1 CreateChildControls method 39 3.7.2 ChildControlsCreated attribute 39 3.7.3 EnsureChildControls method 39 3.7.4 RecreateChildControls method 39 3.7.5 Controls property 40 3.7.6 HasControls method 40 3.7.7 HasEvents method 40 3.7.8 FindControl method 41 3.7.9 Example of implementing composite control 41 3.8 Common development skills 51 3.8.1 DesignMode attribute 51 3.8.2 Masking properties in base class controls 52 3.8.3 Page.Request.Browser property 53 3.8.4 Set control ID specification 53 3.8.5 Enhance FindControl function 54 3.8.6 Mapping server control values to client 55 3.8.7 Prohibit controls derived from CompositeControl from creating child controls 56 3.8.8 Notes on using CreateChildControls 56 3.8.9 Don’t misunderstand the design meta-property DefaultValue 57 3.8.10 Utilizing base class resources in the Render method 57 3.8.11 Conditional compilation & conditional attributes 60 3.9 Summary of this chapter 61 Chapter 4 Server Control Properties 62 4.1 The role of control properties 62 4.1.1 System properties 62 4.1.2 Custom attributes 62 4.2 Simple attributes 63 4.3 Design-time characteristics of properties 64 4.4 Complex attributes 67 4.4.1 Overview 67 4.4.2 Several markup forms of complex attributes 67 4.4.3 In-depth study - complex attribute analyzer 79 4.5 In-depth study - customize your own property editor 85 4.5.1 System Properties Editor 85 4.5.2 Custom property editor 91 4.6 Type converters 126 4.6.1 System type converter 126 4.6.2 Customizing your own type converter 128 4.7 Implementing custom attributes 138 4.8 Summary of this chapter 145 Chapter 5 Events and Data Postback Mechanism 146 5.1 Overview of control events and data postback 146 5.1.1 Events and their meaning 146 5.1.2 Data postback mechanism 147 5.2 Implementation of event and data postback mechanism 148 5.2.1 Client return event interface IPostBackEventHandler 148 5.2.2 Client postback/callback disclosure 150 5.2.3 Return data processing interface IPostBackDataHandler 153 5.2.4 Correctly handle events of controls inherited from base classes 159 5.2.5 Extend the function of KingTextBox control (King TextBoxCanPostEvent control) 161 5.3 Event handling mechanism of composite controls 168 5.3.1 High-efficiency event collection object 168 5.3.2 Customize your own delegate and event parameter classes 170 5.3.3 Event handling of composite controls 175 5.3.4 Autocomplete function control SearchControlIntelligent 185 5.4 Summary of this chapter 193 Chapter 6 Page State Mechanism 194 6.1 Overview of page status 194 6.2 View state mechanism 195 6.2.1 IStateManager interface 195 6.2.2 Loading and saving views phases in the control life cycle 196 6.2.3 Simple type view state application 197 6.2.4 Implementing custom type view state 205 6.3 Control state mechanism 217 6.4 The relationship between view state and control state 221 6.4.1 Using view state even when view state is disabled ViewState Object 221 6.4.2 The IStateManager interface can still be used in the control state 223 6.4.3 Rules for the combined use of view state and control state 225 6.5 Encrypted page status 225 6.6 Clear page status 226 6.7 View state analysis of dynamically added controls 228 6.8 Custom type converter to achieve efficient serialization 231 6.9 Page status performance optimization strategy 238 6.9.1 Storage location optimization - save view state information on the server instead of the client 238 6.9.2 Volume Optimization—Compressing View State Data 240 6.9.3 Chunked storage of view state data 243 6.10 Summary of view state and control state 243 6.11 Summary of this chapter 244 Chapter 7 Customizing custom control theme styles 245 7.1 Overview of control styles 245 7.2 ASP.NET support for styles 245 7.2.1 Working principle and use of Style class 245 7.2.2 WebControl base class’s style support functions and its working principle 249 7.2.3 The HTMLTextWriter class supports control styles 252 7.2.4 Define style attribute rules inside the control 253 7.2.5 Two common conversion methods 256 7.3 Application examples 260 7.3.1 Composite control style and view state 260 7.3.2 Control structure and style separation plan 268 7.4 Summary of this chapter 295 Chapter 8 Control Client Programming Model 297 8.1 ASP.NET server-side control supports client 297 8.2 Detailed explanation of ClientScriptManager class functions 301 8.2.1 RegisterArrayDeclaration method 301 8.2.2 RegisterClientScriptBlock method 302 8.2.3 RegisterClientScriptInclude method 303 8.2.4 RegisterClientScriptResource method 304 8.2.5 RegisterStartupScript method 305 8.2.6 RegisterExpandoAttribute method 305 8.2.7 RegisterHiddenField method 306 8.2.8 GetCallbackEventReference method 307 8.2.9 GetPostBackClientHyperlink method 307 8.2.10 GetPostBackEventReference method 308 8.2.11 GetWebResourceUrl method 308 8.2.12 RegisterOnSubmitStatement method 309 8.3 Client callback 309 8.4 Client control application example 323 8.4.1 Encapsulating JS client objects 323 8.4.2 Encapsulating HTC client objects 343 8.4.3 Online signature control sample application 371 8.5 Some commonly used JavaScript frameworks 385 8.6 Summary of this chapter 387 Chapter 9 Customizing User Controls 388 9.1 Overview of User Controls 388 9.1.1 The role of user controls 388 9.1.2 Understanding System.Web.UI.UserControl Base class 388 9.2 User control application examples 389 9.2.1 Simple User Controls 389 9.2.2 Complex data binding user controls 394 9.3 User control caching 419 9.3.1 Introduction to ASP.NET caching 419 9.3.2 User control caching 420 9.4 Summary of this chapter 421 Chapter 10 Developing Validation Controls 422 10.1 How validation controls work 422 10.1.1 Brief description of built-in validation control 422 10.1.2 Analysis of the working mechanism of the verification control 423 10.2 Implementing custom validation controls 443 10.3 Summary of this chapter 451 Chapter 11 Using Embedded Resources in Controls 452 11.1 Principles of embedding resources in controls 452 11.2 Applying embedded resources in controls 453 11.2.1 Using embedded resources in controls 453 11.2.2 Common embedded resource types and usage 455 11.3 Common browser tools 460 11.3.1 HTTPWatch 460 11.3.2 IE Developer Toolbar 461 11.3.3 Fiddler 461 11.4 Summary of this chapter 462 Chapter 12 Developing Template Data Binding Controls 463 12.1 ASP.NET template attribute control mechanism 463 12.1.1 Introduction to template attributes 463 12.1.2 ASP.NET support for template controls 464 12.1.3 Repeater control template implementation mechanism analysis 466 12.2 Custom control application example 469 12.2.1 Template control function 469 12.2.2 Application examples 470 12.3 Summary of this chapter 489 Chapter 13 Data Binding and Data Source Controls 490 13.1 Data-bound controls 490 13.1.1 Overview of data-bound controls 490 13.1.2 ASP.NET’s support for data-bound controls 491 13.2 Data binding control sample application 501 13.2.1 Control implementation function 501 13.2.2 Application examples 502 13.3 Data source control 508 13.3.1 Overview of data source controls 508 13.3.2 ASP.NET support for data source controls 508 13.4 Data source control sample application 515 13.4.1 Control implementation function 515 13.4.2 Application examples 516 13.5 Summary of this chapter 522 Chapter 14 Extended Control Solution——GridView 523 14.1 Overview of extended controls 523 14.2 Customize GridView multiple headers 523 14.2.1 Function Overview 523 14.2.2 Code implementation 524 14.3 Fixed GridView header and added scroll bar support 527 14.3.1 Function Overview 527 14.3.2 Code implementation 528 14.4 Summary of this chapter 533 Chapter 15 Summary of Programming in Custom Control Design Mode 534 15.1 .NET Framework supports design time 534 15.2 Design-time metadata support 535 15.3 Complex attribute serialization 539 15.4 Type Converters 539 15.5 Property Editor 540 15.6 Introduction to base classes available in design patterns 541 15.7 Design-time support for control rendering 543 15.7.1 Overview 543 15.7.2 Application examples 543 15.8 Autoformat 546 15.8.1 Overview 546 15.8.2 Application examples 547 15.9 Template UI Designer 551 15.10 Intelligent operation list 552 15.10.1 Overview 552 15.10.2 Application examples 552 15.11 Control Designer Area 558 15.11.1 Overview 558 15.11.2 Application examples 558 15.12 Summary of this chapter 562 Chapter 16 ASP.NET Ajax Control Development—— Client 563 16.1 Overview of ASP.NET Ajax Framework 563 16.2 Ajax Library supports client-side object-oriented functions 564 16.2.1 Namespace and Type and Function classes 565 16.2.2 Interface type 568
16.2.3 Class types and object-oriented inheritance features 569 16.2.4 Enumeration types 570 16.2.4 Reflection function 570 16.3 Common types in Ajax Library 571 16.3.1 Ajax Library extension to JavaScript base types 571 16.3.2 Sys.StringBuilder class 576 16.4 Ajax Library requests the server and WebServices 577 16.4.1 Classes in the Sys.NET namespace 577 16.4.2 Request process analysis 578 16.4.3 WebRequest request example 579 16.4.4 Using proxy to implement Ajax call server example 581 16.5 Ajax Library supports control client class development 584 16.5.1 Client control base members (class/interface) 584 16.5.2 ASP.NET Ajax control client life cycle 589 16.6 Client Control Sample Application 592 16.7 Debugging and Tracing603 16.8 Summary of this chapter 605 Chapter 17 ASP.NET Ajax Control Development—— Server 606 17.1 Overview of ASP.NET Ajax Server Controls 606 17.2 Ajax Server Control 607 17.2.1 Ajax Server Control 607 17.2.2 ASP.NET Ajax Extension Control 612 17.3 ASP.NET Ajax base class for server control support 612 17.3.1 Base classes supported by Ajax controls 612 17.3.2 Ajax control application example 623 17.4 Summary of this chapter 636 Appendix A .NET 3.5 technical tutorial series—— Collection/ASP.NET Ajax/SilverLight/JQuery 646