CSS with ASP.NET?

a few questions, i'm hoping anyone/everyone can give me feedback

1) in developing applications with asp.net, should all html contain asp.net controls (ie replacing simple <table> with <asp:table> and whatnot)? what is the generally accepted best practice around this?

2) even though asp.net supports style attributes for almost all of its controls, isn't it still better to use a .css file to control all the stylistic considerations of your application? is this not possible? should it be .css for all general and then .aspx-level for any special-case styles?

3) i haven't been able to find many extensive resources on the use of css stylesheets with asp.net. much of it focuses on using the webform-level style attribute, but personally i think this is messy and bleeds format into function.

thoughts?This should've been posted in the ASP.net forum... could the resident mod move it there?I think it's in the correct forum, but that hotnow is just a bit muddled.

By the time the markup has gotten to the browser, the ASP.net code has been completely forgotten about. Therefore you should use ASP.net to output your markup and either link to/import a .css file in the head of your document.

Here is an example of one of my ASP pages (not ASP.net but it'll do as an example).
ASP:<%@ language="VBscript" %>
<% option explicit %>
<!--#include file="initiate.asp"-->
<%
call top(" > Past Blogs")
call archive()
call bottom() %>markup:<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>

<title>Quite Rude > Past Blogs</title>

<meta http-equiv="content-type" content="application/xhtml+xml;charset=iso-8859-1" />
<meta http-equiv="content-script-type" content="text/javascript" />
<meta http-equiv="content-style-type" content="text/css" />

<meta http-equiv="pics-label" content="(pics-1.1 'http://www.icra.org/ratingsv02.html' comment 'ICRAonline EN v2.0' l gen true for 'http://www.quiterude.com/' r (nz 1 vz 1 lz 1 oz 1 ca 1) 'http://www.rsac.org/ratingsv01.html' l gen true for 'http://www.quiterude.com/' r (n 0 s 0 v 0 l 0))" />

<meta name="author" content="Phillip Freeman and David Harrison" />
<meta name="copyright" content="© Copyright 2004 Phillip Freeman and David Harrison" />
<meta name="description" content="Random and serious discussion website." />
<meta name="designer" content="Phillip Freeman and David Harrison" />
<meta name="keywords" content="xhtml, html, css, asp, cross, browser, phillip, freeman, lavalamp, david, harrison, accessible, probes, quite, rude" />
<meta name="language" content="English" />
<meta name="robots" content="all" />
<meta name="subject" content="Random and serious discussion website." />
<meta name="title" content="Quite Rude" />

<meta name="doc-class" content="living document" />
<meta name="rating" content="random" />
<meta name="revisit-after" content="3 days" />
<meta name="robots" content="all" />

<link rel="shortcut icon" href=http://www.webdeveloper.com/forum/archive/index.php/"/skins/abstract/favicon.png" type="image/png" />

<style type="text/css" media="screen">
@import url(/skins/abstract/styles.css);
</style>

</head>

<body>

<h1><span></span>Quite Rude</h1>

<div id="outer1">
<div id="outer2">


<div class="bloglist">
<h2>Past Blogs</h2>

<ol>

<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"comment.asp?blog=9">A Funny Experience</a> (13 Comments)</li>

<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"comment.asp?blog=8">New Name</a> (17 Comments)</li>

<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"comment.asp?blog=7">A Level Results</a> (21 Comments)</li>

<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"comment.asp?blog=6">More links</a> (10 Comments)</li>

<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"comment.asp?blog=5">PC stuff</a> (11 Comments)</li>

<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"comment.asp?blog=4">A fortnight of work</a> (20 Comments)</li>

<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"comment.asp?blog=3">New Features</a> (26 Comments)</li>

<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"comment.asp?blog=1">People, we have blog-off</a> (15 Comments)</li>

</ol>
</div>


</div>
</div>

<div id="other">

<dl>
<dt>Site Navigation</dt>

<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"/" title="Main Page">Main Page</a></dd>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"/archive.asp" title="Past Blogs">Past Blogs</a></dd>
<!-- <dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"/recent.asp" title="Recent Comments">Most Recent Comments</a></dd> -->
</dl>

<dl>
<dt>Serious Linkage</dt>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.1976design.com/blog/" title="Dunstan Orchard's personal blog site.">1976 design</a></dd>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.autisticcuckoo.net/blog.php" title="Life, Jeeps and Web Standards">autistic cuckoo</a></dd>

<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.meyerweb.com/" title="Eric Meyer's personal blog site.">meyer web</a></dd>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.mezzoblue.com/" title="mezzoblue § design, typography, and the web: live from vancouver, b.c., canada">mezzo blue</a></dd>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.ryanbrill.com/" title="Ryan Brill - Personal Thoughts and Ponderings">ryan brill</a></dd>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.simplebits.com/" title="Dan Cederholm's personal blog site.">simple bits</a></dd>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.stopdesign.com/log/" title="Stopdesign | Log Archive">stop design</a></dd>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.zeldman.com/" title="Jeffrey Zeldman Presents The Daily Report">zeldman</a></dd>

</dl>

<dl>
<dt>Peer Linkage</dt>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://personified.complexfellow.com/" title="Personified: Ben Rogers' Personal Website">complex fellow</a></dd>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://cmm.sonoracabinets.com/jona/" title="Jona's Blog :: Blue Panther">jona</a></dd>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://skinneralamod.netfirms.com/" title="Ben's Personal Website">skinner a la mod</a></dd>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.thenamesdan.com/" title="Daniel Tomasiewicz's Personal Website and Blog">the names dan</a></dd>

</dl>

<dl>
<dt>Web-comic Linkage</dt>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.biggercheese.com/" title="Bigger Than Cheeses">bigger cheese</a></dd>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.mbcomics.com/" title="Monobrow Comics!">mbcomics</a></dd>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.penny-arcade.com/" title="Penny Arcade!">penny arcade</a></dd>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.questionablecontent.net/" title="Questionable Content: New comics every Monday, Wednesday, and Friday">questionable content</a></dd>

</dl>

<dl>
<dt>Admin</dt>
<dd><a href=http://www.webdeveloper.com/forum/archive/index.php/"/admin.asp?action=logout" title="Log out.">Log out.</a></dd>
</dl>

</div>

<p class="counter">
So far 7147 lepers have been dismembered.
</p>

<div id="toclear"></div>

</body>

</html>As you can see, in my case, the markup doesn't even remotely look like the ASP code used to produce it. Here (<!-- m --><a class="postlink" href="http://www.quiterude.com/archive.asp">http://www.quiterude.com/archive.asp</a><!-- m -->) is the page I used for the example.

All styles have to be applied client-side because that is where the page is rendered.

By the way, I noticed that you used <table> as an example, I hope that doesn't mean you use tables for layout. ;)ASP and CSS are apples and oranges. The special .NET (webforms?) tags should be used in the IDE and the runtime should render them as standard HTML widgets. All presentation should be handled with CSS. Yes, if you apply formatting to the webforms tags then that formatting will be imbedded as inline with the rendered tags and will probably contain a lot of prorietary cruft.
 
Back
Top