Reputation: 168
I need to display a page of panels, each panel being a set of tests that are are pulled from the database. Each panel will have user input, input validation, JavaScript alerts etc.
I'm thinking of making each panel a UserControl, then passing an Id via eval to the user control. Is using user controls like this bad practice? Is it better to have the panels nested in the GridView directly?
Upvotes: 0
Views: 21
Reputation: 1392
A panel and a user control are both objects. They are essentially the same thing. User controls are more easily reusable, think of it like a pre-built panel. It's not really 'bad practice' to do either.
What you should really think about is what is inside the control. If it is something that requires significant code (generating avatars, getting account information, loading extra information from a DB, etc) then a user control is better.
But keep in mind those sorts of things can be intensive for each one, which can devastate performance.
A better bet is loading everything into a list of View Models first and then just passing the pre-existing data into the control. At which point, user control or panel doesn't really matter.
I personally would probably choose user control for compartmentalization and organization. Unless it just has a label or something. Then it's probably overkill.
Upvotes: 1