Introduction to Web Custom Controls
Web custom controls are compiled components that run on the server and that encapsulate user-interface and other related functionality into reusable packages. They can include all the design-time features of standard ASP.NET server controls, including full support for Visual Studio design features such as the Properties window, the visual designer, and the Toolbox.
Note Web custom controls are not to be confused with Web user controls. For more information, see Recommendations for Web User Controls vs. Web Custom Controls.
There are several ways that you can create Web custom controls:
- You can compile a control that combines the functionality of two or more existing controls. For example, if you need a control that encapsulates a button and a text box, you can create it by compiling the existing controls together. For more information, see Developing a Composite Control.
- If an existing server control almost meets your requirements but lacks some required features, you can customize the control by deriving from it and overriding its properties, methods, and events. For more information, see Developing ASP.NET Server Controls and Web Server Controls Hierarchy.
- If none of the existing Web server controls (or their combinations) meet your requirements, you can create a custom control by deriving from one of the base control classes. These classes provide all the basic functionality of Web server controls, so you can focus on programming the features you need. For more information, see Developing Custom Controls: Key Concepts and Developing a Simple ASP.NET Server Control.
Security Note At design time in Visual Studio, your code always runs fully trusted, even if the code will eventually be in a project where it would receive less-than-full trust at run time. This means that your custom control might work properly when you are testing it on your own computer, but might fail due to lack of adequate permissions in a deployed application. Be sure to test your controls in the security context in which they will run in real-world applications. For more information, see Code Access Security.