Curtis Swartzentruber

in

August 2005 - Posts

New compilation options in ASP.NET 2.0
The compilation options available in ASP.NET 2 are a bit overwhelming compared to what's available now.  I'm still struggling a bit to get my head around it. I had some problems over the weekend on the conversion I'm doing.  I'm trying to get my personal site converted over to ASP.NET 2.  Amazingly, it's not the code that's giving me problems as much as it is the new project structure and compilation options.  Scott Guthrie just posted this which answers at least some of the questions I have. But there is definitely a bit of a learning curve involved here. Ironically enough, people new to ASP.NET might actually have an easier time than those of us who think we know what we're doing.  So much has changed it's going to take a bit of a mindset switch to really understand best practices for different types of projects.
Posted: Aug 22 2005, 02:38 PM by cswartz | with no comments
Filed under: ,
10 Tips For Moving Towards Web Standards Part 2
And now for the stunning conclusion of my 10 tips <g>
  1. Begin from the inside out
    As a followup to tip#5 (move towards tableless formatting)...
    It can be tough and intimidating to move away from table-based formatting all at once.  And there are still some types of layouts that are tough to do with divs. especially if you are just getting started with CSS.  Rather than giving up before you get started, take some baby steps. An easy way to do this is to start with your nested tables first.  There are plenty of instances where it is trivial to replace a table with a div structure, assuming you use static widths.  See how many nested tables you can replace with structural HTML elements instead.  Using a blend is better than doing nothing at all.
  2. Use percentage values for font sizes.
    In the body or html style in your stylesheet, you can set your font to a specific pixel (or other unit of measure) size.  Some people will even say you shouldn’t do that, but it seems like a decent compromise.  Then in every other style, set your font-size as it relates to that size.  So for instance, you might make <H1> 120%.  Make sure to say 100% if you want the same size.  This makes it much easier for your page to scale properly if people want to play with the font sizes.  Layouts also tend not to fall apart as easily.  One caveat to this, in certain nested style scenerios, your size will be a percentage of the parent style, not the main font size, so keep that in mind if something isn't working quite as you expected.
  3. Use inline styles sparingly.
    The current version of Visual Studio uses inline styles a lot, which I don’t like because it makes it tough to Cascade styles properly (the C in CSS).  There are a lot of tricks with cascading that people don’t even realize you can do.  Cascading often allows you to build up a consistent UI without a substantial amount of work and keep things more consistent.  In Visual Studio 2005, there is a move away from those towards themes/skins.  One example is the way you can skin an ASP.NET control, like a datagrid, so that all your datagrid styles can be consistent across your site and you don't have to format every single grid.  This is also a nice change in that what is left in your datagrid control declaration are attributes that control the function of the datagrid, like paging, datasource, etc.  Makes it much easier to see what's going on, once again separating function from presentation.  A good trend.
  4. Let go (more flow-based).
    When you have the option, DON’T control the layout so much.  See where you can get away with letting the page gracefully adjust to changes in browser width, font sizes, etc.  This also makes it easier to move towards techniques like skinning or themes, which will be a big part of ASP 2.0.  If you thought deciding what page width was best to support, it's going to get tougher.  People are going to be accessing your site from phones, PDAs, their cars, their internet-enabled fridges...  Okay, maybe not that last one for awhile.  But you get the idea.
  5. Read up
    There are tons of good resources on CSS, both online and in books.  You would be amazed at how much a bit of concentrated study will teach you.  I learned a ton from just the first 2 chapters of the Eric Meyer on CSS book.  There are also plenty of cool design sites pushing CSS. You can generally see what they are doing using View Source and also by viewing the stylesheet.  Get the Web Developer Extension for Firefox. A good exercise is to take one of your current pages that uses table layout and attempt to recreate it as closely as possible using only HTML layout elements like divs and CSS.  You'll be amazed at what you can learn rather quickly.
As I keep saying, there are a lot of things in Visual Studio 2005 that will help you move towards standards.  I hope to get into some specific examples in future posts.


Posted: Aug 17 2005, 12:11 PM by cswartz | with no comments
Filed under: ,
10 Tips For Moving Towards Web Standards Part 1
As developers begin to work with ASP.NET 2.0, it's a good time to look at existing code and attempt to bring it in line with the latest standards.  Visual Studio 2005 is going to work with you to move towards using CSS, XHTML and other modern standards for web design.  As you prepare for ASP.NET 2.0, here are some tips you can start using today to get ready.

  1. Dump the clear gif for spacing
    Unless you have some need to support an old browser with poor or no CSS support, there is really no excuse to be using transparent gifs for spacing.  You can get so much more flexibility out of padding and margins around elements. And pretty much any modern browser supports these attributes consistently, given you pay attention to tip #2.  There are some aspects of CSS 2 that can vary a lot between browsers, but margin and padding tends to work reasonably well.
  2. Use the right DOCTYPE
    Here is what you want at minimum ...
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" http://www.w3.org/TR/html4/strict.dtd>
    Don’t use transitional unless you have a good reason (this is the default in Visual Studio 2003, so be sure to check it).  Transitional puts IE into quirks mode, which causes all kinds of weirdness around CSS.  I’ve seen pages that didn’t line up, bad margins, etc. in IE that were fixed simply by moving to the 4.01 strict doctype.  Keep in mind this won't let you use frames (why are you still using them again?).  Frames are deprecated and won't be supported going forward.  If you want some alternatives, here's a good place to start:
  3. Test in a different browser
    Even if you are in a corporate environment where everyone uses IE 6, check your pages in Firefox or Opera.  IE is notorious for letting you get away with bad markup, like missing table tags.  And you’ll also more easily find inconsistencies in your formatting, even if you are already using CSS.  It’s not that much more work to get most sites working in all modern browsers and that’s what VS 2005 is going to try to do, so get used to it.
  4. Close all tags
    Yep, even <br/>.  One of the reasons pages with ASP.NET v1 controls don’t validate is because ASP.NET controls don’t do this right today.  Plus, you’ll quickly run into problems applying styles consistently if you don’t make sure to properly nest and close tags.  It's not much more work and your site is going to work better. Plus it's required for XHTML compliance.
  5. Move toward table-less formatting
    People are tired of hearing this, but tables are for tabular data, not page layout.  It’s surprising that an almost 10 year old technique for formatting is still with us.  Once you start using DIVs  for formatting, you'll see how it really opens up so many possibilities.  And you can actually see your content rather than having it dribbled throughout a bunch of tags.  I’ve seen pages drop in size by 30-60% by moving away from nested tables.  Some people say with so many people on broadband, who cares about page size anymore. But pages are also getting bigger as far as the amouns of data coming down, javascript and so on.  Plus, pages are being accessed from devices, phones, etc. It’s still a good idea to optimize page size and browsers also have an easier time figuring out what the heck you want the page to look like.
So there's the first 5 tips, 5 more coming in the next post.
Posted: Aug 12 2005, 01:56 PM by cswartz | with no comments
Filed under: ,
Why standards and why now?
Whenever I start talking about standards and CSS, the question is inevitably – WHY?  Isn’t what we are doing now good enough?  Isn’t it better to use tables for layout, after all Microsoft does it and I know how to do it and I can get it done faster and all that.  It amazes me that the same people who would die if they had to use traditional ASP again think nothing of using the same design techniques they learned 5-10 years ago.  And granted, Microsoft tools have done nothing to help the situation and have actually hurt the move towards standards and CSS.  The Visual Studio IDE combined with IE is a one-two punch that keeps a lot of developers bogged down in old design patterns.

The good news is that the story gets a lot better with VS 2005 and ASP.NET 2.0.  All of a sudden we have a tool that doesn’t just support standards, it helps you validate against them.  It targets cross-browser and cross-device support by default.  All the web controls are XHMTL-compliant.  Hats off to the Web Tools team for bucking the trend and giving developers the tools they need to move into the next generation of web development.  Here are some other answers to the why question:

  1. Future proof – Future browsers are going to expect XHMTL markup.  Getting into stuff like AJAX is going to be a lot easier if you follow standards.  The expectations for a Web user interface is being shaped by companies like Google.  Things are going to start getting much more complex.
  2. Maintainability – Which is easier, changing the height tag on a clear gif on 100 pages or changing the padding in your stylesheet and watch it fix the whole site?  Once you have a site based on CSS, it becomes much more trivial to adjust colors, formatting, visibility, etc.  And don’t get me started on trying to figure out a layout problem when you are 15 tables deep into a nested table structure.
  3. Separate content from presentation – It becomes much easier to edit the content of your site if you aren’t digging through all kinds of extra markup.  Easier to do personalization and localization.  Plus it’s just good practice, along the lines of encapsulation that most developers inherently understand.
  4. Accessibility – Easier access for people with disabilities, screen-readers have an easier time figuring out your content flow.
  5. All the cool kids are doing it - Seriously, there are a lot of smart people pushing this stuff, including people like Scott Guthrie on the ASP.NET team.  Sooner or later, people are going to start asking why you aren't taking a standards approach, especially if you are a consultant writing web applications for a living.
There are plenty of other good reasons, but those immediately leap to mind.  In the next few posts, I'm going to throw out some tips about moving towards standards in your own development.
Posted: Aug 10 2005, 02:44 PM by cswartz | with 1 comment(s)
Filed under: ,
My life as a web developer
My girlfriend Kristin was bored at work a few weeks ago and decided to Google me. She was surprised at the number of pages of listings (Google has over 835 results for me). I reminded her that come to think of it, I’ve been working online for over 10 years now. Hard to believe. Got me thinking how all this got started….

My first job where I did anything with the web was at R.E.X. Music, a small independent record label. I tried to start up an email list, managed by hand at that point of course. I knew nothing of listservers or anything that fancy. We also had a bit of web presence, but it was hosted and managed elsewhere.

From there my next major job was with SkillSearch Corporation, who had a resume database (pre-web). Around the time I started there, they were realizing that the web was going to make their main business obsolete, so they were trying some new stuff online. When I first started, they had a simple website hosted and designed by a web company out of, wait for it… Silicon Valley. This was 1996. My old boss used to boast about having the first career related banner ad online through the now long defunct GNN service, which was well on its way to getting its butt kicked by AOL.

I had played around with HTML a little bit and gradually started digging into our site and was like “I can do this myself”. So I ended up redesigning the site , we moved our hosting in house and I eventually went on to do several generations of sites for a couple different recruiting apps we had. You can still see some of my “handiwork” in the Wayback Machine. SkillSearch.com

At some point we wanted to do more dynamic sites and started using ASP, VB components and SQL Server 6.5, believe it or not.  SQL Server 7 had just been released and we quickly moved to that.  I started learning about databases and ASP code.

I started seeing the writing on the wall due to some business decisions (SkillSearch was about to go under) and jumped ship to help out with a new music eCommerce site for a music distributor in Nashville.  I was in a bit over my head at first, really writing VB components for the first time and using MTS/COM+ Services.  The architecture was actually pretty good for the time, we were working with Billy Hollis’ old company and they had the web app thing figured out for the tools they had to work with.  So it was a good training ground for me.  My boss was also pretty open about letting me learn new technology and be involved in the community. I jumped on .NET very early and we were running our sites (both internal and external) on .NET within a few months after the 1.0 release.  I also got involved more with the online community at that point, answering questions on the ASP.NET forums and the old LearnASP lists and then the ASPAdvice lists.  I started blogging in early 2003.

All that to say, I've been involved with web apps for awhile now, but we may just be entering another very interesting phase in the evolution of the web and how we use it. In just the Microsoft world, between ASP.NET 2.0 and AJAX, things are about to get very interesting.  We are going to start doing things with web applications that we just couldn’t do before.  As with any change, developers on the Microsoft platform are going to find their world take on a different appearance.  All of a sudden standards matter and the toolset is going to enforce and assist with that much better than before.  Having your app work with a variety of browsers and devices is going to be expected.  Through this blog I hope to share some things you can start doing now to ease the transition and also talk about some of the exciting things coming for web apps, particularly if you develop using the Microsoft platform.

Posted: Aug 09 2005, 09:15 PM by cswartz | with no comments
Filed under: ,