Chapter 6. Custom controls

 

This chapter covers

  • An introduction to how to build custom controls
  • Composite controls
  • Handling PostBack in custom controls
  • Complex controls
  • Data binding and templates in custom controls

You can use custom controls in ASP.NET Web Forms to benefit from componentization. As you learned in previous chapters, ASP.NET Web Forms are based on the concept of controls, which are used as placeholders for their given features. Controls are useful when you’re developing complex applications because you can avoid code duplication. Because custom controls are objects, you can use the typical features offered by OOP.

You can start from scratch with your own control, or use an existing control and enrich it. Depending on your needs, you can interact with the Web Form during PostBacks, or support data binding (introduced in chapter 5).

One of the most interesting aspects of custom controls is that you can encapsulate your logic and reuse it many times in your application, without rewriting it. This feature will be a great help when you need to enhance the control even more because the modifications will reflect automatically.

When you’re dealing with custom controls, you need to have a solid understanding of how ASP.NET Web Forms work because you’re more exposed to some internals than you are in other situations. If you need to brush up on ASP.NET Web Forms, be sure that you’ve read chapters 4 and 5.

6.1. The basics of custom controls

 

6.2. Complex controls

 
 

6.3. Advanced controls

 
 
 
 

6.4. Summary

 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest