8.3. Practical Tips on User Controls
The following list provides some practical tips on working with user controls.
Don't overuse user controls. User controls are great for encapsulating repeating content, but they also make it a little harder to manage your site because code and logic is contained in multiple files. If you're not sure if some content will be reused in another part of the site, start by embedding it directly in the page. You can always move it to a separate user control later if the need arises.
Keep user controls focused on a single task. Don't create a user control that is able to display five different types of unrelated content with a property that determines what to display. This makes the control difficult to maintain and use. Instead, create five lightweight controls and use them appropriately.
When you create user controls that contain styled markup, don't hardcode style information like the CssClass for the server controls contained in the user control. Instead, consider creating separate CssClass properties on the user control which are then used to set the CssClass of your server controls. This improves the reusability of your user control, making it easier to incorporate the control in different designs.