I like ASP.NET, I really do, especially with .NET 3.5, C#, with VS2008. It's fun and rewarding.
But...I have just a few gripes I'd like to mention: inline styles, leaky abstractions, and ID mangling. These are the challenges that I have dealt with so far with ASP.NET.
First: inline styles and stupid HTML. If you've done any serious ASP.NET work where you care about the HTML markup, you are already coping with this gripe. ASP.NET controls can be very cool, but they can also generate some stupid HTML come runtime.
For instance, the ValidationSummary. This is a handy control to list all the form errors for your user, and it works great with the built-in validators, which I am a fan of. But have you looked at the markup it generates? You get an inline style with something like color:red;font-style:bold; or something like that. What the...? Why would you presume that I wanted that? It also generates a div around the unordered list of errors. Seriously!? Why not just let me put the div around it if I want to?
Solution: Set ForeColor="" and the inline styles will go away. You'll just have to live with the div for now--which isn't the worst thing ever.
Next: the checkbox list. This is a great control that renders as a freaking table! Why!? Why not just...I don't know...a LIST OF CHECKBOXES? I'll admit that I have used this control anyway, because it's just so darn handy. Alternative solution: repeater full of checkboxes. Annoying.
Here's a new one for me that sparked this whole blog post: do you know that if you set a checkbox to "Enabled=false" in the code-behind, that it will not only set the checkbox to "disabled" (which is fine), but it will also inexplicably put a span around the checkbox and put an attribute of disabled="disabled" on the freaking span!? I don't think that has ever been valid in any iteration of HTML/XHTML. Why, Microsoft, why?
Solution: Step 1: remove brain. Step 2: instead of Checkbox1.Enabled = false;, use Checkbox1.InputAttributes.Add("disabled", "disabled");. Step 3: Replace brain.
Another gripe: ASP.NET controls are basically abstractions of normal HTML inputs, but they can be very leaky. For instance:
asp:TextBox TextMode="multiline" MaxLength="20" runat="server" /
That is valid ASP.NET code. However, a "multiline textbox" in normal HTML would be a textarea, which has no maxlength property. So...fail. There's no workaround for this, folks, sorry; you just have to stay on your toes.
Finally: ID mangling. If you name your ASP Textbox "txt_box", that's not what it will be when it reaches your users. It'll be something like ctl00$ContentPlaceHolder1$txt_box. No biggy, except that if you want to use jQuery/JavaScript on a specific ID, you are out of luck (unless you want to crowd your jQuery on to the same file and write out the ClientID's at runtime).
A workaround is to use CSS classes instead of ID's, and just treat those CSS classes like singletons, but now we're losing some semantics, aren't we?
I could go on, but enough griping. There is actually a solution to all of the above that doesn't involve a cheesy workaround, hack, or basically rewriting the controls' rendering code yourself:
CSS Friendly Control AdaptersGo back to ASP Classic or switch to PHP- ASP.NET MVC!
That's right, ASP.NET MVC, everyone's favorite alternative to WebForms. ASP.NET MVC doesn't have a ViewState, doesn't mangle ID's, and you can use plain old HTML controls (or more likely, HTML helper functions) without sacrificing control over your form. You can use jQuery much more easily. You have much more granular control over markup. Er, and I heard there are a few other benefits as well...seperation of concerns and what-not.