Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 23, 2012 05:21 PM by Horizon_Net
Feb 23, 2012 04:00 PM|LINK
User Controls are useful because you can encapsulate the logic inside it and reuse the control more times in the web application.
I want to know if it is a good practice to increase the logic of a user control for using it more times in the web application or if it is better to duplicate the user control and change the logic in the new control to mantain the code esier to understand
for the developer.
So is it better to reuse the control more times and to have more logic complexity or is it better to duplicate the user control more times and having easier logic to understand?
Feb 23, 2012 04:38 PM|LINK
well there are two purpose of a user control:
1.) create a complex control which cannot be created using out of the box server controls.
The logic inside can be complex but should be dependent in any sense.
Feb 23, 2012 05:21 PM|LINK
it depends on your requirements. If you want to have a generic control it could become complex, but it will fit into more scenarios. If you want to have a control which is only created for one purpose (in a sense of reusability) you should keep it simple
(it only should do for what it is created and the rest should be handled anywhere else).
For the simple scenario: You can create a base control from which other controls (depending on their purpose) can inherit and add additionally complexety. That should be the best way if you follow an OOP design, reusability, and understanding.