Sales, marketing, project managers and even IT managers always
seem to latch onto the concept of building a web part to provide
custom functionality in SharePoint. I'm always being asked to
create a web part for various tasks which just complicates things.
In reality 95% of the time a web control will do the job just fine,
or better yet a user control.
A web part usually dictates that you will be dynamically
creating asp.net controls at runtime or writing HTML tags in
managed code. Both of these techniques are pretty horrible and
provide no separation between logic and presentation. There are
many examples of this on CodePlex.
A user control has a few key advantages over web parts:
-
Easier development
User controls provide a design time surface and allows easier HTML
integration
-
Easier deployment
There are less steps required to make a user control available in
a SharePoint site
-
Less unwanted HTML
Web parts and the web part framework include additional HTML bloat
that decreases accessibility
That said there are a few good reasons why you would want to
build a web part:
-
Reusability
If the component is going to be used in multiple pages
with different configurations
-
Admin control
Web part properties provide a convenient way for admins
to manage settings
-
Collaboration
Where users or content authors want to be able to add web
parts to their own pages
If you decide that you do need a web part, I would still
advocate using a user control. You can either use something like
SmartPart, or preferably just embed it yourself as it's a very
simple task. By embedding a user control to a web part in a 1-1
relationship, you have the opportunity to use web part properties
as well as providing the best user experience.
The same theory can be applied to field controls. Another option
when creating web parts is to use XSLT to control the display. I
believe this is a great approach as it provides good separation
between logic and presentation, makes it easier for integrators and
promotes accessible HTML.
I guess web parts just sound cooler?
Resources: