Yes you have complete control by spitting out html, I some times get the
idea those that limit themselves to controls have trouble with html. If you
know your html well anything is possible, no matter how well controls are
made they can not think of everything
I would be interested to know of some specific situations in which
controls /should/ be able to make something easier but cannot. I'm
actually more of a PHP guy than one of ASP or ASP.net, so I normally
program web applications in a half-procedural, half-object-oriented
way that requires "spitting out" HTML directly from PHP (controls,
event-driven processing, etc not available without additional
frameworks, although I use a framework that doesn't have those things
anyway). I don't find ASP.net controls hindering of control of HTML at
all.
Let's look at some situations.
Say one wants to get some data from an XML file, any sort of database,
or something that one has created a custom provider for. One has some
elaborate plan for presenting the data to the user, perhaps it's a
photo album with a lot of features and one wants to display photos in
a grid. Someone who isn't familiar with controls may immediately drag
'n' drop a GridView control out of their Visual Studio toolbox, and
then have trouble getting the thumbnails to display in rows as well as
columns, side by side and above one another. With custom code it could
probably be done, but as someone who isn't familiar to controls, one
would not want to bother with that.
This is a result of stepping one (or more) controls too far. The
GridView control will handle getting the data (if using an additional
provider control), iteration, and output. It will also cover
organization of the data, and can take care of pagination and sorting.
But in the situation of a photo album, one only benefits from it's
ability to get the data and iterate for you. One can get this
functionality with the Repeater control, and do the output oneself. In
this case, ASP.net is not outputting anything for them; it takes care
of the basics: getting the data and giving each record of data to them
with which one can do what they like. Further embracing the theory of
controls, one can use custom code to make use of the GridView's
sorting and pagination features if they are willing to deal with some
debugging that may be needed because it is their first time doing such
a thing.
In another instance, one is in a centralization kind of mood and they
want to create an RSS button control. All they want to do is create a
control that outputs a simple image/link that links to the RSS feed
whose name (a unique identifier) is specified in one of the control's
properties. This is just for speculative reasons...maybe they have
many feeds on their website and syndication buttons are all over, and
the names of the RSS feeds are stored in a database with their
locations. This would be done in a user control (.ascx) by creating a
HyperLink control (utilizing it's ImageUrl property to put an image in
it) and setting its NavigateUrl property from code-behind, simply
getting the appropriate RSS feed location from the database.
However, since you say that you like more direct control over your
HTML, that is completely possible with a control, which is why I bring
this example up. What someone like you could do is create a server
control (a class like my example in my previous post) that outputs the
HTML directly. This could be done with a .ascx control file also, but
with little or no advantage.
Of course, there are instances in which a control should not be used
in the first place, which may be what you're talking about. However,
it is taken by other USENET posters that you realize that this is
obvious and not the purpose of controls anyway. One such case could be
an RSS feed. Creating an RSS feed control would imply that it is meant
to be placed on a web form (.aspx), although that is once again
"stepping too far". Web form files have many extra features that could
be problematic in an RSS feed, which is simply XML. Therefore, it
would be illogical for an RSS-feed-writing tool to be a control. In
this case, one should make a class that does the feed writing, so it
can be used in a Generic Handler file (.ashx). This allows very direct
control over the entire process of outputting the page, eliminating
all of the things that ASP.net can do when it assumes the output is
HTML for a browser such as pushing xHTML conformance.
Being too paranoid of ASP.net's control over one's output can be a
problem when trying to develop with ASP.net, because as a RAD
platform, it tries to do things for you and make your life easier.
Although it is /possible/ for automatically sticking the alt attribute
in image tags or something like that to cause a problem for you, it's
a very uncommon situation relative to how many times an Image control
is used by ASP.net developers. ASP.net's features can't account for
every little possibility, but it does a good job of making more things
possible with it's extendability. If ASP.net can't do magic for your
assignment, either you're doing it wrong or you should just do it the
good old way of "spitting out HTML" from the same file, code,
subscript that gets the data and is part of the page. Since there are
so many situations in which controls are useful, there shouldn't be
much reason to complain about the few things they can't help you with.
-Michael Placentra II