J.B. said:
[...]
I also don't know why you'd bother with an open/close tag for an
empty-content element. Why not just:
<asp:Label ID="suitLabel" runat="server" Text="Club" />
I agree. I've never seen anyone use #2. That's just stupid.
You probably haven't done much ASP.Net then (either that or you do all
your coding using Notepad), because by default in the Visual Studio
IDE, if you type "<asp:Label", the moment you hit the ">" sign, the
closing tag is inserted for you. [...]
If you type a '/' before you type the '>', it won't add the closing tag.
Which is, of course, how one would type it in without the closing tag
anyway.
I don't see how it's an IDE problem.
I really wasn't implying it was a problem with the IDE, I just found
it difficult to believe that someone could do a significant amount of
work in ASP.Net with VS as the editor and never see an example like
the stated one. I've worked on a lot of different ASP.Net projects
since the release of .Net and I see that all the time -- I'd even say
its fairly common.
You're correct. Please excuse my hyperbole. Maybe I should have said:
"I've never seen anyone write #2." As you say, if you're using ASP.NET
WebForms (and especially if you're using drag and drop from the Toolbox)
then you're likely to see it a lot.
However, if you were sensible enough to bypass WebForms and use an MVC
framework - like Castle's Monorail - then you wouldn't have to put up
with such ugly HTML as you get to use NVelocity.
Alternatives are now everywhere. Have you tried OpenRasta and the Spark
view engine, for example?
Microsoft has seen the light, so now you also have ASP.NET MVC and the
Razor view engine to play with.