Search code examples
.netcontrolsascx

When is the right time to say: "Now I need to create a user control!"


When do you consider creating a user control in .NET? Do you have some basic criteria to exclude your code from the page and introduce a new user control?

Usually I tend to follow those to decide whether I need a user control or not:

  • When the page seems to be more readable with a separate user control
  • When some part of the form looks like to be used from different pages again and again

Solution

  • I suppose it follows the following:

    • Do I need to separate this component out from the common code?
    • Do I use this item often, meaning I need to keep recreating it?
    • Do I need to be able to template this to suit different styles?