views:

78

answers:

4

In my current project, we use lots of user controls. Large user controls (500+ lines code) are breaked up to a few small user controls for easy maintenance.

My question is: most of the user controls are not reusable in other places, but this kind of user control based development complicate the communication between controls, e.g. events are everywhere.

What's your idea to use User Controls?

+1  A: 

Often times I'll use an ASCX not necessarily so it can be re-used, but to isolate its functionality away from the ASPX. This works great for a navigation menu or a pair of pull-down menus that are used to select city & state for an address form.

The key here is that I don't want my ASPX to be a mess of micro-behaviors, I want the page to represent a macro behavior.

Now, I know this is all pretty abstract, and I don't always do it this way, but that's how I tend to use the technology.

JMP
+1  A: 

User Controls are reusable within an ASP.NET app. To make it reusable across apps, custom web control will be better but the pain of creating it deterred many. Some resort to duplicating codes.

Here's one article which might help: http://geekswithblogs.net/dotnetrodent/archive/2006/06/16/82136.aspx

o.k.w
A: 

Personally I avoid user controls if the equivelant custom control is easy to implement.

I also avoid breaking out user controls unless they are going to be reused.

Like you said, event management and reusability across projects is a pain with user controls.

cbp
A: 

Use User Controls like you used to use Include files in classic web programming. User Controls are more feature rich because they are fully object-oriented; however they're not necessarily easily reusable. Beyond the server-side include ability, trash User Controls in favour of Custom Web Controls.

Or maybe I'm just a windbag. Here's Microsoft's suggestions about when to use them.

John K