ASP.HATE
I like to complain about all of the Microsoft-created languages because they sometimes just scream "I'M TRYING TO ACT BACKWARDS-COMPATIBLE EVEN WHEN I'M NOT!" My latest hate can be directed towards the "runat" attribute.
When working with an ASP.NET script, you can put ASP.NET components in using XML tags like
<asp:Button ID="MyButton" Text="Click Me!" runat="server" />. Notice the "runat" in there? It signifies that the server preforms actions on the object from the code file associated with the script. If you omit it, the compiler gives you an error, saying that the attribute has to be there. If you put anything ELSE in there, "browser" perhaps, and it yells at you: "server" is the only accepted value.SO, we have a compiler that can tell which components require to be run on the server, and a specification that doesn't allow any modifications to an attribute that has to be there. Why is this still around? I think it is useful for those people moving from old ASP, where this might have actually had meaning. I could see the use of allowing someone to write that, but it shouldn't be necessary. I hate writing that in there when it is strongly implied and inferred.
I'm sure Spomer, the ASP expert who reads this blog, could shed some light on this issue. He may actually know what he's talking about.

1 Comments:
Well, since I've been invoked (though normally you have to say my name three times), I'll comment... Actually, I'm not a fan of it at all, but I think there are two main reasons:
1. ASP.NET can be used to render just about any kind of text markup, not just (X)HTML. It's also used for tons of different kinds of proprietary mobile phone markup languages. Requiring runat=server gives a little more freedom as to what kinds of things can go in the page. What if you wanted to use the XML namespace "asp" in your page? In ASP.NET, as long as there's no runat=server, you can stick as many asp:button tags in there and they won't screw things up.
It's actually legal ASP.NET markup; it's just Visual Studio (and maybe the optional ASP.NET precompiler) that doesn't like it.
2. You can put runat=server on any element and it suddenly becomes programmable, which is occasionally useful. You can manipulate that element just as if it were an actual ASP.NET control. It would be weird to have runat=server on "fake" ASP.NET controls but not require it on the real ones.
I don't know if those are the official reasons or not, and I think they're kinda lame. But, they're just a mild irritant to me; certainly not something to inspire hate. Hate is something better saved for VB's abominable CType operator.
Post a Comment
<< Home