views:

486

answers:

8

I know Microsoft has made efforts in the direction of semantic and cross-browser compliant XHTML and CSS, but it still seems like a PitA to pull off elegant markup. I've downloaded and tweaked the CSS Friendly Adapters and all that. But I still find myself frustrated with bloated and unattractive code.

Is elegant, semantic CSS with ASP.Net still a pipe dream? Or is it finally possible, I just need more practice?

A: 

As long as you use the Visual Studio designer, it's probably a pipe dream. I write all of my ASP.NET code (all markup, and CSS) by hand, simply to avoid the designer. Later versions of Visual Studio have gotten much better at not mangling your .aspx/.ascx files, but they're still far from perfect.

DannySmurf
A: 

A better question is: is it really worth it? I write web applications and rarely does the elegance of the resulting HTML/CSS/JavaScript add anything to the end goal. If your end goal is to have people do a "view source" on your stuff and admire it, then maybe this is important and worth all of the effort, but I doubt it.

If you need the semantics, use XML for your data. I do believe in the idea of the semantic web, but my applications don't need to have anything to do with it.

Jason Bunting
A: 

As DannySmurf said, hand building is the way to go.

That said, you might look at Expression Web. At least it is pretty accurate in how it renders the pages.

Chris Lively
+11  A: 

The easiest way to generate elegant HTML and CSS is to use MVC framework, where you have much more control over HTML generation than with Web Forms.

Kevin Dente
IF LOVIN' MVC IS WRONG, I DON'T WANNA BE RIGHT
Jarrod Dixon
This quote is getting _so_ overused :L
A: 

@JasonBunting - Yes, it's absolutely worth it. Semantic and cross-browser markup means that search engines have an easier (and thus higher rankings) time with your content, that browsers have an easier (and thus less error-prone) time parsing your content for display, and that future developers have an easier time maintaining your code.

ceejayoz
+1  A: 

See this question for more discussion, including use of MVC. This site uses ASP.NET and the markup is pretty clean. Check out the HTML/CSS on MicrosoftPDC.com (a site I'm working on) - it uses ASP.NET webforms, but we're designing with clean markup as a priority.

Jon Galloway
A: 

Yes - it's a pipe dream. Since working with a professional web designer on a joint project who HATED the output of ASP.net server side controls I stopped using them. I essentially had to write ASP.net apps like you would write a modern PHP app. If you have a heavy business layer then your page or UI code can be minimal.

I've never looked back since. The extra time spent writing everything custom has saved me a great deal of time trying to make Visual Studio / ASP.net play nice with CSS/XHTML.

BPAndrew
A: 

i can't believe nobody has mentioned css adapters. many of the common controls used in asp.net (gridview and treeview for example) can be processed through an adapter to change the resulting html that is outputted to the browser.

if going the mvc route isn't a viable option, it is possible to write your own adapters for any of the built in asp.net controls.

http://www.asp.net/CssAdapters/

cowgod
Probably due to the fact that I stated I already use them in my original question. Thanks though!
dewde