Thursday, March 26, 2009

Showing the Date and Time in .Net

I like the concept of master pages, they seem sort of like includes on steroids. In Classic ASP, I would build my template and use includes for those items that would be global to the site: header, footer, navigation, etc. master pages in .Net let you do the same sort of thing.

So I get my master page created and I want to put the copyright notice on the footer. But how to dynamically insert the year?
d, day of month: System.DateTime.Now.ToString(" d") // can't use just "d"
dd, zero-padded day of month: System.DateTime.Now.ToString("dd")
ddd, abbreviated day of week: System.DateTime.Now.ToString("ddd")
dddd, full day of week: System.DateTime.Now.ToString("dddd")
h, hour: System.DateTime.Now.ToString(" h") // can't use just "h"
hh, hour, zero padded: System.DateTime.Now.ToString("hh")
H, hour, 24-hr: System.DateTime.Now.ToString(" H") // can't use just "H"
H, hour, 24-hr, zero padded: System.DateTime.Now.ToString("HH")
m, minute: System.DateTime.Now.ToString(" m") // can't use just "m"
M, month: System.DateTime.Now.ToString(" M") // can't use just "M"
MM, month, zero padded: System.DateTime.Now.ToString("MM")
MMM, month abbreviated: System.DateTime.Now.ToString("MMM")
MMMM, month full name: System.DateTime.Now.ToString("MMMM")
y, year (omits century): System.DateTime.Now.ToString(" y") // can't use just "y"
yy, 2-digit year, zero padded: System.DateTime.Now.ToString("yy")
yyyy, 4-digit year, zero padded: System.DateTime.Now.ToString("yyyy")
So to actually use this in a page, you'd do:
Copyright <%= System.DateTime.Now.ToString("yyyy") %> 
This will write the full four-digit year.

Here's a full list of all the Date and Time formats.

Visual Web Developer 2005 and ASPNETDB.DBF

I've decided to initiate my .Net journey with the free Visual Web Developer 2005 Express Edition, mainly because the couple of books I have are for Visual Studio 2005 and the .Net 2.0 framework. I choose SQL Server 2005 Express as well for the database backend.

I'm not sure how easy it is to get VWD-2005-ED anymore. Microsoft released VWD-2008 about 6 monmths agao and it's all that's available from the official .Net website. I had a CD with it that had come with the Dummies book I bought a few years back. I bet you could find it on PirateBay or some other torrent sharing site though. It's free, so that's not stealing AFAIC.

It's taken me some time to figure out the nuances of getting a new web site project up and running. The main issue I was having was with VWD-2005-ED creating the membership database the way is was supposed to. Sometimes the membership database got created and sometimes it didn't.

After much trial and error, I hit on a sequence of actions that seems to work. I assume you have VWD-2005-ED and SQL Server 2005 Express installed, and have started the VWD program. Do:

File-->New WebSite-->ASP.Net Web Site - I'm working in C# and using the File System as the location

Once the program has created the site:

Build-->Build Website

Once the site has been built, hit control (Ctrl) F5 to launch the site preview in Internet Explorer. Close the browser after it finishes launching and then, back in VWD:

Website-->ASP.Net Configuration

This brings up the browser again with the configuration stuff loaded. It might take a minute or two. Once it's done, the ASPNETDB.DBF should have been created.

RetroWebDev Blog Update & Social Bookmarking Tool

With my intent to chart my progress through the Sargasso Sea of .Net development, I decided to update my blog with the new templates/features now offered by Blogger. I'm now taking advantage of the hand-dandy gadgets that are so easily installed, and have integrated the AdSense ads between the posts. (Not that anyone ever clicked on the old AdSense ads, but hope springs eternal.)

One of the things I wanted, and operating under the delusion that people might actually find certain posts here interesting and want to share, was an easy way for visitors to do the social bookmark submission thing.

A quick search took me to AddThis, where I quickly and easily got hold of the handy bookmark button now seen below all posts. You do have to register to get the tool, but heck, I'm registered on a gajillion sites already anyway. What's one more?

So welcome to RetroWebDev's slight new look.

Monday, March 23, 2009

The Inevitable Move to .Net

I don't want to. I've been resisting for years. I'm very fortunate; although my job as a Software Engineering Manager (government sector) requires me to be familiar with the concepts and capabilities of .Net, I've never had to actually write code. Because I am old and lazy and set in my ways, I've continued to use Classic ASP for all my personal projects. When I do dig in to help on a programming, it's usually on the SQL/T-SQL end.

From a development philosophy perspective, I still hold this resolute belief: The User Doesn't Care. All the user wants is to see certain information presented in a certain way after they take a certain action. They couldn't care less about the extension on the end of the filename - .asp, .aspx, .php, .cfm, .html - it just doesn't matter. Show the page, let the user take some sort of action, and show the results as quickly as possible, all using a visually pleasing and easy-to-use interface.

And what are web applications really? Nothing more than a framework for:

putting data in
getting data out

The only people who care about what language is used are developers (because they have a skill and they want a job), and management (because they read in some magazine that language XXX is the thing to use and all the industry is going to it or already on it).

But the time has come to jump int the cesspool of .Net. Why? you ask. Marketability. There are a lot more programming positions out there than there are programming management positions. When the inevitable happens (and sooner or later it will) and I need to find a new job, I need to be able to actually FIND A JOB. And I want to find one without have to relocate.

So....

I'm starting a new project and I'm going to use it as my impetus to learn .Net using C#. Hey, I taught myself Classic ASP and SQL/T-SQL. How hard could it be? Yeah, right....

I'll post here as progress and learn things, things I already know how to do very well, but now have to relearn because someone, somewhere, decided to dump Classic ASP and create .Net. I hope he chokes on a chicken bone.

If I had it to do all over again (and this is my advice to anyone interested in getting into web application development) I recommend the LAMP route:

Linux
Apache
MySQL
PHP

Many big corporations and large sections of the government are still wedded to the Microsoft platform, but even there you can see PHP and other languages making some inroads. Wordpress blogs are all over the place (check out CNNs blogs). Recovery.gov, the new governemnt website about the ongoing financial recovery efforts, is built with the Drupal CMS, which is open source and developed in PHP.

For an out-the-gate, web development programming language, you can't go wrong with PHP. If you decide to expand your skills later, well, you can expand your skills later. But if you don, it will probably be by choice rather than necessity.

Wednesday, March 04, 2009

Kittens Born

I won't bore you with the whole story; suffice to say that the outdoor cat we 'adopted' gave birth to her kittens on Sunday. Welcome to the world!