Friday, June 16, 2006

Migrating to Mac: Part 3: Tale of the two Syncs...

One of the things that I knew would be an issue with my new Mac was syncing me PDA. I have an old O2 XDA II Pocket PC (Phone Edition). Anyone who has used a PocketPC Phone knows that the only way to use it is with a PC. Keeping your contacts and appointments synchronised across the devices is important. Getting something to sync the Mac with the PDA was critical.

I decided to setup a sync program as one of my first tasks. So after installing Office 2004 and copying my e-mail across I started searching for a solution. I found that there are two main solutions PocketMac and The Missing Sync. From my initial reading PocketMac appeared to have been around longer and had a few extra features. So I paid, downloaded and installed PocketMac.


PocketMac was a little tricky to get working correctly and does not work with USB on the new Intel Macs. Their web site indicates that it is a Mac problem that they have to work around, I should have realised something was wrong when I read this... Anyway, I eventually got it working with Bluetooth. It worked ok for one day, and then... it stopped working. I'm not exactly sure what went wrong. I was in the process of installing a variety of other programs so what was conflicting with what was not something that I could work out. I followed PocketMac's troubleshooting advice and eventually, after about 5 hours of reading logs and experimenting, I eventually gave up and posted a support request. I posted their trace report, and made sure that I outlined most of what I had tried. After a day I got back a post of their "Dont use USB, use Bluetooth". So they didn't even read any of my help request. I replied, and after another day they esclated it to their next support level. I waited, and waited, and well nothing. After a week and a half I gave up on them and asked for a refund. Looking back, their product was not really well polished, and their web site is not very professional.

So yesterday I purchased The Missing Sync for Windows Mobile. After such a bad experience with PocketMac I prepared for the worst. Their web site has a section on migrating from PocketMac, which I thought was interesting. I followed their instructions and rid my Mac and PocketPC of their software. With this done I set about installing The Missing Sync. The install went smoothly. I plugged in my PocketPC and started the Sync. A connecting overlay appeared on screen and the PocketPC tried to connect to the Mac. This was a nice addition, the status shows which state the connection is in something that wasn't provided by PocketMac. Anyway the bad news at this point was that it failed to connect... I was not overly concerned as in the attempt to connect with PocketMac I had played with many settings on the PocketPC. I renamed the PocketPC for sync purposes then tried connecting again. This time everything worked. I setup the partnership which overrode the PocketMac partnership on the device. The sync was a little slower than with PocketMac. However, it works and provides feedback on where it is up to which is always good to see. The Missing Sync program is far more polished, as is their web site. I cannot comment on their support as I haven't needed it. The Missing Sync also connects via USB and Bluetooth, both of which are working fine for me.

Both PocketMac and Missing Sync are able to sync contacts with Entourage, or the Mac Address Book, and appointments with Entourage or iCal. So you dont need Entourage to make use of these.

Note: I didn't try renaming my PocketPC with PocketMac. This may have corrected the issue I was having. However, I dont know and I'm not going to reinstall it to try.

Wednesday, June 14, 2006

Migrating to Mac: Part 2


Having received my Mac the first task I had was to migrate my e-mail, contacts, and appointments. On my notebook I have been using Outlook 2003, so the plan was to switch to Microsoft's equivalent program on the Mac. The first issue was finding what that product was called. I had incorrectly thought that it would still be called Outlook... With some googling I became familiar with the Entourage product, the mail/contacts/appointments program in Office 2004 for Mac.

As we have licenses for Office for Mac I installed the suite which was a very pleasant process compared to the same process on a PC. Insert the CD start the installer and the hard work is all done. Before I could get up the installer was finished. Having used a PC for so long I am used to the hours of waiting while office installs and registers everything...

With Entourage installed the next step was to migrate my data from Outlook 2003. Cant be that difficult I thought to myself, after all it is Microsoft -> Microsoft. Open Entourage, which looks great its not just a simple port of Outlook, and then start looking for import. Entourage can import mail from csv files, mbox, earlier versions of office for Mac, but not any of the Outlook for Windows products. Ok... Goggle time.

There are several ways of performing this migration.


  • MacUser has a very convincing article noting that Microsoft has released a converter. When you get to the Microsoft site you find that it can only import from previous Mac versions.

  • mvp.org has a page that lists a few options including using an IMAP or Exchange server neither of which I had access to. They also offer links to some scripts to do this. These seem overly complex for the task in my opinion.

  • There is a product called O2M. For $10 this is a good option. It can transport mail, contacts, appointments, etc. from Outlook to mbox, iCal, etc formats that you can then import on the Mac. I used the trial version but was too cheap to purchase it for the one off transfer of data.



The approach that I used is explained by Dave Riches and also on the O'Reilly Network. This process involves converting the e-mail in your Outlook PST file into individual mbox files that can then be imported into Entourage.

The process that I followed best matches Dave's process.

  1. Install Thunderbird, which has the ability to import PST files and internally it stores its mail as mbox files.

  2. Copy files to Mac

  3. Drag mbox files into Entourage


The process is simple enough except that I arrange my mail into a hierarchy of folders. When you import your mail into Thunderbird it will create a folder for each mail folder in Outlook. Each of these folders then contains its subfolders and a mbox file with the mail from that folder. There was no way that I was going to drag all of these individual files into Entourage. However, the files are now just simple text files and can therefore be altered via the command line.

The first thing that I decided to do was to compact some of my folder hierarchies. I did this at a Command Prompt on my Windows machine. The command to do this is:

(for /F "delims=" %i IN ('dir /s /b *.') DO @type "%i") > NewMailFile.mbox


Execute this command in the folder that you want to compress the mbox files into. In my case I kept a folder with all of my internet site subscription e-mails (like blogger, feedburner, bloglines, etc). I have subscribed to many sites! I executed this command in the folder containing my "Internet Sites" mailbox, compressing these into a single mbox file.

At this point I copied all of the mbox files to my Mac. Thunderbird does not add an mbox extension to its files and unfortunately Entourage will only import them if they have the mbox extension. The following command run at the Mac Terminal, in the directory where you copied your mail files and folders.

find . -type f -print -exec mv "{}" "{}.mbox" \;


With this done you can now drag each of the mbox files into Entourage. The import is complete.

With my mail in Entourage I then proceeded to transfer my contacts and appointments. As I use a PDA I did this by syncing Outlook with my PDA and then syncing the PDA with Entourage. In order to do this I purchases PocketMac Pro. Once I got it installed and followed the instructions it synced all of my contacts and appointments. PocketMac itself worked for a couple of days but lately it has stopped working. I'm not sure what else I have installed that could cause this problem and the PocketMac support is very slow. If this is not resolved soon I am going to try The Missing Sync for Windows Mobile, v2.0, unfortunately they don't have a trial version otherwise I would have switched sooner. (If anyone has any advice on this let me know...)

Tuesday, June 06, 2006

Migrating to Mac: Part 1


Recently I decided to get a new notebook. My current notebook is a Toshiba S1 with 1GB RAM and a ATI Mobile 9000 card. I needed to upgrade for several reasons. Firstly I need more RAM. I do distributed .NET development and presentations on the notebook and I want to run multiple Virtual PCs at once. One running a web server, another for the app server and one for the database server. With 1GB of RAM I can run one virtual machine but the others are really pushing it. Secondly I want to play around with Vista, I need a DirectX 9.0 graphics card. With this in mind I started looking for a notebook to meet my needs.

Needs:
- Presentations and office document creation (PowerPoint, Word, Excel)
- .NET development (3-Tier demonstrations... with 3 tiers)
- DirectX 9 capable (for Vista)

I have been reading about Apple's MacBook Pro and this started to look like a viable alternative. Apple offers a nice package, well thought out design, good hardware spec, with the capability of running both MacOS and Windows. Other notebooks offer similar features, but not the entire package.

I spent some time finding out the capabilities of the MacBook in relation to my requirements. A quick watch of the Fast OS Switching and related videos appear to demonstrate the ability for the MacBook to meet my most important requirement, multiple virtual machines. The main issue with these videos is that they are usually running only a web browser in each virtual machine. I need to do more. Based on the machine spec I believe that it will be capable of meeting my requirements.

So the Plan became:
* Get a MacBook Pro 2.16GHz with 2GB RAM (and faster disk).
* Get Office 2004
* Migrate Outlook to Entourage (Office 2004's equivalent to outlook)
* Install Parallels
* - Setup multiple virtual machines to enable distributed .NET development
* Install Boot Camp
* Install Vista in VM Ware within XP

This plan has recently been put into action. I have now received my MacBook Pro and have started the migration process. A few issues have arisen since I received the notebook. I need the following:

1: a keyboard that supports both Mac and Windows.
2: to be able to sync my PocketPC with Entourage
3: to be able to sync music with my Zen Neeon

The keyboard issue was one that I had not thought of before. At home I used a Logitech Cordless MX Duo that has drivers for both Mac and Windows, so problem solved. I will cover the other details as I go.

In the next part I will look at migrating my contacts and mail from Outlook to Entourage.

Tuesday, May 30, 2006

Thinking in Objects

Finally got around to starting the new Object Oriented Programming subject today. I have now selected a text that I hope will work out well. The Object Oriented Programming subject is going to use C# as the implementation language, though it will focus on Object Oriented Programming and design rather than on the language and related libraries...

The book I am going with (and yes it is too late to change now) is "Object Design: Roles, Responsibilities, and Collaborations". I have skimmed over most of it and now read chapter one in detail. It looks really good. The initial focus is on understanding design concepts. I think this is a good start. For the first lecture I have created a "Everything C#" followed by "Building programs with objects" presentations. The first is a bit shock and awe, covering most of the C# syntax, but that needs to be done somewhere and I want to get it out of the way so we can start on the real material. The second presentation looks at what objects are and how we build programs using them. I am happy with how it has turned out so far. Another Beyond Bullet Points success, I hope.

Week one is mostly out of the way. I have found an online tutorial for learning C# so that will be the lab work. The structure for the presentations is out of the way, and I have the text to fill in the design gaps that I am leaving. Its great being able to focus purely on objects knowing that these guys will have some idea about what programs are and their internal workings.

More to come as this unrolls...

Tuesday, May 23, 2006

MacSaber

The real reason for me getting a MacBook is now out!.

Blogging as a PSD

So you are a uni student now. Why should you blog? Blogging is a great way of letting others know about the cool and interesting stuff that you are doing. Found a cool web site, got some new hardware, done a great assignment, played with some new tech, want to comment on your lectures... All of these are great blog topics.

Keep your blog reasonably professional and it can become part of your online profile that you can use in your resume. Shows employers that you are interested in IT. When you review something new upload a review to your blog and it will also show that you are capable.

Get a blog now, and let others (me included) know about it. I'm ready to subscribe...

Thursday, May 18, 2006

The Security Guy

I have attended a number of presentations over the last week, and one has really stuck with me... Unfortunately not because of how good it was. The presentation was about the current state of internet security. The person was really passionate about identity theft, but was way over the top with his message. The result was that anything of value was lost...

My recall of the presentation goes as follows:

You use fly buys - wow... Don't use fly buys
You use internet banking - wow... Don't use internet banking
You don't encrypt your hard drive - wow...
don't leave your computer on...
don't access the internet
You use internet explorer - wow... Don't use IE
You use office - wow don't use office
(now let me go a little further...)
don't use a computer
don't cross the road
don't drive a car
don't carry cash
don't deal with banks
don't deal with people
Become a hermit and remove yourself from society

That is the logical extension of the presentation...

Now unfortunately there was no real advice. There was nothing of value that you could take away from the presentation. In a work environment many people use Office, they are going to need to. Saying don't use office is not going to help. Saying, office has a large number of issues, these are the main ones, this is what you can do to avoid many issues, these are the risks that you cant avoid, etc. That would be useful, you can take something away from the presentation. Just saying 'don't use it' is really a waste of time. I use it every day and I'm still here...

If you give a presentation think about what your audience is taking away. If there is nothing for them they will not be satisfied.

Tuesday, May 16, 2006

Media Center

I can now say that Media Center has been a real success. Last week Alison said that we should get "something" so that we could connect the TV in the bedroom to the Media Center. Life with standard TV is no longer acceptable. The next part of the conversation went "We should get another 360 for the bedroom", "Yes ... something like that". This comment has been strongly denied :)

I will look into the cost of getting another Media Center extender, but if the cost of getting a 360 drops then that will be the desired device.

Big ticks for media center.

Friday, May 12, 2006

XBox = Sport

Microsoft and NewsCorp are banding together to create a professional gaming league...

"News Corp will aim the big guns of DirecTV, IGN Entertainment and Fox Interactive Media at the project, which is likely to glorify Microsoft Xbox games"

Tuesday, May 09, 2006

My first step toward becoming a pod person

Well I have asked for a MacBook Pro and even before I get it I'm thinking how I can use Mas OS X rather than windows for a number of things... Get Office for Mac, Free Pascal works, get the mono c# compiler. hmmm so what will I use windows for?

Well I still love Visual Studio. So Parallels can host a virtual PC for me with Windows and I'll run Visual Studio in that as I need to. Thats what I do at the moment on my PC anyway (except with Virtual PC rather than parrellels).

With some luck I'll get approval and start looking at dual booting with Vista soon!

Talents

I have been thinking about people's talents and their study choices.

If you are talented in some area, and you enjoy it, should you seek to advance this or study other areas which are more "in favor" with industry at the time?

As a faculty of ICT we have been blessed with many students lately. Most of these had little talent or interest in ICT. (I'm sure that they all have talents, just not in ICT) These students obviously thought that it was better to study something that is in favor than to study what they are good at and interest in...

In my opinion I would always choose to build upon my talents than to go with current trends.

Having said this, I haven't always done this. I studied a Business/IT degree even though my real talents and interest lay in software development. At the time I didn't realise what I was doing. The degree that I studied came with a scholarship and the money helped make a real difference. I also didn't realise what I was missing. No one ever bothered to say "Hey your good at this. Did you know that there is all this other stuff that you may also be interested in..." I ended up doing well in my degree and getting a job that I hated. Being a proactive person within 6 (painful) months I got myself another scholarship and went back to uni to learn as much of "the other stuff" as I could. The only problem was that I was now doing it on my own. If I had my time again I would choose to do a technical IT degree, and do IBL to get some extra $.

Anyway the question remains, should you follow your interests (and talents), or study areas which have job shortages and hope to build interest and talent? What are your thoughts on this?

Monday, May 01, 2006

Late Weekend

Wow, am I tired. This weekend was a struggle. Its good to be back at work.

Friday night I decided to extend the WinGraph Pascal unit to include the ability to load and draw images on the screen. Finding the code to load bitmaps in the Win32 API is much more difficult than from the .NET RTL. Once I found the code getting it to work didn't take long, though I did make a few really simple mistakes (like passing b then a to a procedure rather than a then b) that took a while to find. Once I got the code basically working I modified the MazeGame and made a little graphical version. Sleep - 1

On Saturday we decided to buy a new TV Tuner and HDD from the Media Center PC. I remember reading somewhere that Media Center can support upto 3 TV tuners, so we planned to get the Fusion Dual tuner and a 300GB HDD. The purchase went ok, and we spent the next part of the day shopping for my brothers birthday present. Got home around 4ish and thought that I would install the HDD and TV Tuner quickly... Big mistake. Basically installed the TV Tuner, and HDD (at the some time) and booting windows failed. My first thoughts were, "damn TV tuner card". Removed the card and tried again. Same problems, wouldn't even post this time. Something did not like the new HDD. Removed the other tuner card, and the wireless network card. Basically the same problem. Got a little further then the machine froze. Change cables, change SATA ports, repeat, repeat, repeat... Anyway, at 6 we went to my brothers party which was great fun. Didn't even think about the PC for a few hours. Got home about midnight and started it again. Thought I had it working, formatted disk (almost 1hr). Then post failed again... Crap. Finally gave up on HDD.

Next trick was to install the tuner. Which turned out to be easy. Plug in, follow instructions. All working in about 1/2 an hour. Go into Media Center, turn them on and get the error "Select one or two tuners only". ARGH... Upto 3 turns out to mean "2" outside US, or "3" (1 digital, 2 analog) in US. Bummer. I could have saved some $$$ and just got another the same as the one I had. So at 3:30 I head off to bed.

Sunday I went to take back the HDD. The guys I got it from check it and it worked ok in their machine. Not much good to me, but they suggested a bios update. So back home update bios. Same problem. Install original drivers, same problem. Install latest drivers, same problem. Back to shop with PC. The technician had told me "Bring it in and I'll have a quick look at it.". When I took it back he wanted $35 to have a quick look at it... Stuff that. There is nothing left for him to change. The customer service rep and technician were quite rude, and unhelpful. I now know why you should use MSY, everyone I know who has had a problem with their equipment has been well treated. Anyway after a little arguing I got them to exchange it for another brand of disk. "There is a 10% repacking fee", fantastic, the customer service here just gets better and better. So I ended up with a 250Gb HDD and a little change + some happy memories. I had always wondered why the shop had so many "Email complaints to ..." signs around the store. Now I know.

Spend the remainder of the day driving around shopping for other things. Finally got home about 6:30pm and installed HDD. Amazing (sarcastic), it worked. First time, no problem. I had some drivers issues with the Tuner card, which I reinstalled. So everything is working well now.

Last thoughts, don't shop anywhere that has a prominent "complaints" signs. You may have to queue for a while, but MSY is worth the wait.

Tuesday, April 25, 2006

XBox 360 + Media Center

Wow am I loving my 360 and Media Center PC. This year for my 30th birthday I got an XBox 360, my birthday is in February and this meant a long wait for the actual machine. During this wait I did some research on what you can do with the 360 and I discovered Media Center. Basically this setup allows me to store my media on the PC and stream it to the 360 for output.

So how has it been? Well having had the 360 for a month now I can safely say its been as good as I had hoped. Most of my music is now recorded in MP3s on the PC, allowing it to be shared between Media Center, Media Player and iTunes. The music plays perfectly on the PC and 360, as well as on my Zen and Alison's iPod. TV watching has also changed. I now try and pre-record everything that I want to watch. The TV guide (once setup) allows Media Center to automatically record all of the shows that I watch. I also have the digital photos on the Media Center PC, and am currently playing with setting up albums, and seeing if I can add audio (you can play these together manually, I want to see if there is an option for creating and saving this)

Games for the 360 have also been great. I got the VIP pack with Perfect Dark Zero, but I haven't played it much, the other games I got are far too addictive. Oblivion is my number one game at the moment, and I have clocked over 30hours game play already (on one set of batteries for the controller as well, you can buy a lot of batteries for the price of the recharger kit...). I still feel that I am only just getting started with this game. Every time I play it feels like such a huge world, great game.

The other game I'm playing is Need for Speed Most Wanted. After hitting 30hours on Oblivion I thought that I should play this a little, and have been hooked on it since. Love the graphics and game action. Basically it was a toss up between NFS and PGR, and I chose NFS mainly due to price. It was more expensive and there was an "all games $75" sale, so I saved more by getting it. Why not both? I'm an academic, so $ are not in great supply :(. Main problem with my choice is that all the others I know get PGR and not NFS... No big deal, I am loving the game. Just hit #9 on the BlackList and the races are starting to get really challenging. Should be good.

Problems? Well I have had some. The 360 has crashed on me a couple of times in Oblivion with disk read errors, and also in NFS. This hasn't happened so often that I feel the need to take it back, but if it happens more I will be. Other than that everything has been great.

So what's next? Well I need more disk space on the PC for all the media I have. I also want to get some extra tuner cards so that I can record and watch more than one channel at once. Then there is a steering wheel for the 360, and more racing/adventure games. For the moment I need to save some $... but that's nothing new :)

For anyone on XBox Live my gamertag is "The MS Guy"... See you online.

Monday, April 24, 2006

LA Times runs a feature Beyond Bullets

This LA Times article examines the Beyond Bullet Point approach. Front page of the business section. Very impressive.

Thursday, April 06, 2006

Making progress

A small group of students stayed back with me after the lab last night. It was really great fun! We extended the maze game to include the monsters and then went further to improve the monsters movement, and this morning one student talked to me about adding multiple monsters. This is a very funky little program now. I have added a screen shot below. Basically the player can move the "person" around in the maze while the monsters will move themselves. The code for this is available from the above links, there is a maze txt file at the end of the first iteration. The Pascal compiler is free and open source.

Tuesday, April 04, 2006

Students and Learning

One of my favorite (modified) sayings is:

"You can lead a student to material but you cant make them study"

This is the joy that I am having at the moment. Motivating first years to actually study is a lot harder than I thought. Today I looked at how many people are actually looking at the Discussion Board. This is used for all important messages to students (such as when assignments are released, general feedback, guidance, suggestions, etc). Most of these messages are not communicated in any other way.

The following image shows the number of accesses to the Discussion Board by student. There are about 80 students of which 45 have never accessed a single discussion board posting.



Evil plan 1: Make sure that I release much more help via the discussion board... :)

Evil plan 1 is going into action today when I am releasing the assignment... I told them it would be available this week and that I would announce it on the discussion board. Lets see how many actually paid attention in class... My bet is about 35 :)

Thursday, March 30, 2006

Blog Moved

Today I got thinking about where to host my blog again. This time I decided to actually do something about it. I am going with blogspot. Fortunately I used a feedburner feed which I have now redirected. Anyway its good to finally have a place where this can live without worrying about if it is going to be around next week...

Using Full Text Searching with SQL Server

The MurrayBookshop allows users to search for books using SQL Servers Full Text Searching. This works resonably well but could be better.

Currently we use a constructed SQL string that is run via sp_executesql. This is required as we perform paging using SELECT TOP x, where x is a variable based upon the page selected, and the number of records per page. With SQL Server 2005 the SELECT TOP command now allows a variable number of records to be selected so this can then be re-designed to be much simpler.

The other problem is that uses may type anything into the search box. Unfortunatly the full text search does not allow any text to be used to perform the select. To overcome this you need to watch for two errors when using Fill from a SqlAdapter. (base.FillDataSet uses a SqlDataAdapter with the passed in command).

try
{
base.FillDataSet(newData, _BrowseCommand);

return new ProductBrowseResponse(request, newData, (int)_BrowseCommand.Parameters["@TotalPages"].Value, (int)_BrowseCommand.Parameters["@TotalProducts"].Value, ok);
}
catch(SqlException e)
{
if(e.Number == 7619 || e.Number == 7603)
{
return BrowseProductsWithoutSearch(request);
}
else
{
throw new DatabaseTechnicalException("Error browsing for products", Connection.ConnectionString, e);
}
}
A cutdown version of the select command is shown below. This selects the second page of 10 records that match the text in @SearchStringSQL.

SELECT Product.[ProductCode], Product.[ProductTitle], [Rank]
FROM [Product]
INNER JOIN
( SELECT ProductCode, ProductTitle, Rank
FROM
( SELECT TOP 10 ProductCode, ProductTitle, Rank
FROM
( SELECT TOP 20 [Key] As ProductCode, ProductTitle, Rank
FROM FREETEXTTABLE(Product, ProductTitle, @SearchStringSQL) AS KEY_TBL
INNER JOIN Product ON KEY_TBL.[Key] = Product.ProductCode
ORDER BY Rank DESC, ProductTitle ASC
) AS Table1
ORDER BY Rank ASC, ProductTitle DESC
) AS Table2
) AS TABLE3 ON Table3.ProductCode = Product.ProductCode
ORDER BY Rank DESC, Product.ProductTitle ASC;

The BrowseProductsWithoutSearch performs the same query without the full text search.

Password Strength Indicator

(Apologies for the format of this post)
(Feel free to use this, but if you do please let me know)

The other day I registered a friend with MSN Messenger and was impressed by their password strength indicator. Today I decided to implement my own. The results are below.

Basically I use a regular expression to evaluate the strength of the password. Weak = 6 characters at least, Medium = a combination of characters, and numbers, Strong = combination of characters, numbers, and special characters.




The JavaScript is:

<script language="javascript">
var ieDOM = false, nsDOM = false;
var stdDOM = document.getElementById; function initMethod()
{
//Determine the browser support for the DOM
if( !stdDOM )

{
ieDOM = document.all;

if( !ieDOM )

{
nsDOM = ((navigator.appName.indexOf('Netscape') != -1) && (parseInt(navigator.appVersion) ==4));
}
}

passwordChanged();
}

function getObject(objectId)

{
if (stdDOM) return document.getElementById(objectId);
if (ieDOM) return document.all[objectId];
if (nsDOM) return document.layers[objectId];
}

function getObjectStyle(objectId)

{
if (nsDOM) return getObject(objectId);

var obj = getObject(objectId);

return obj.style;
}

function showDefault(objectId)

{
showCell(objectId, "#E2E2E2", "#E2E2E2");
}

function showCell(objectId, foreColor, backColor)
{
getObjectStyle(objectId).color = foreColor;

getObjectStyle(objectId).backgroundColor = backColor;
}

function showWeak()

{
showCell("pwWeak", "Black", "#FF6666");

showDefault("pwMedium");

showDefault("pwStrong");
}

function showMedium()

{
showCell("pwWeak", "#FFCC66", "#FFCC66");
showCell("pwMedium", "Black", "#FFCC66");

showDefault("pwStrong");
}

function showStrong()

{
showCell("pwWeak", "#80FF80", "#80FF80");
showCell("pwMedium", "#80FF80", "#80FF80");
showCell("pwStrong", "Black", "#80FF80");
}

function showUndetermined()

{
showDefault("pwWeak");
showDefault("pwMedium");
showDefault("pwStrong");
}


function passwordChanged()
{
var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
var enoughRegex = new RegExp("(?=.{6,}).*", "g");


var pwd = getObject("txtPassword").value;
if( false == enoughRegex.test(pwd) )
{
showUndetermined();
}
else if( strongRegex.test(pwd) )
{
showStrong();
}
else if( mediumRegex.test( pwd ) )
{
showMedium();
}
else
{
showWeak();
}
}
</script>



The password strength indicator table is:

<TABLE style="BORDER-RIGHT: black thin solid; BORDER-TOP: black thin solid; FONT-SIZE: 75%; BORDER-LEFT: black thin solid; BORDER-BOTTOM: black thin solid"

cellSpacing="0" cellPadding="0" width="100%">

<TR>

<TD id="pwWeak" style="BORDER-RIGHT: black thin solid" align="center" width="34%" title="Has at least six characters">Weak</TD>

<TD id="pwMedium" style="BORDER-RIGHT: black thin solid" align="center" width="33%" title="Has a mix of numbers, lower & upper case characters.">Medium</TD>

<TD id="pwStrong" align="center" width="33%" title="Has numbers, special characters, lower & upper case characters.">Strong</TD>

</TR>

</TABLE>



And this required an action to be added to the txtPassword. As this is ASP.NET we use the following in the page load event for the class:

txtPassword.Attributes.Add("onKeyUp", "passwordChanged()");

Hiding controls in ASP.NET

If you use control.visible = false for controls in your web application these will not be rendered to the resulting HTML. If you want to interact with the control via Javascript there are going to be problems...

Fortunatly one of my Enterprise .NET students found a potential solution. Try the following in your web applications:

control.Style.Add("display","block"); // makes visible
control.Style.Add("display","none"); // makes invisible

Thanks for finding this solution.

The following script can be used to show and hide controls based on the state of a checkbox.

<script language="javascript">
var ieDOM = false, nsDOM = false;
var stdDOM = document.getElementById;

function initMethod()
{
//Determine the browser support for the DOM
if( !stdDOM )
{
ieDOM = document.all;

if( !ieDOM )
{
nsDOM = ((navigator.appName.indexOf('Netscape') != -1) && (parseInt(navigator.appVersion) ==4));
}
}

checkedChanged();
}

function getObject(objectId)
{
if (stdDOM) return document.getElementById(objectId);
if (ieDOM) return document.all[objectId];
if (nsDOM) return document.layers[objectId];
}

function getObjectStyle(objectId)
{
if (nsDOM) return getObject(objectId);

var obj = getObject(objectId);
return obj.style;
}

function show(objectId)
{
var objs = getObjectStyle(objectId);
objs.visibility = 'visible';
}

function hide(objectId)
{
var objs = getObjectStyle(objectId);
objs.visibility = 'hidden';
}

function checkedChanged()
{
var chkBox = getObject('chkBox');

chkBox.checked ? show('txtCreditLimit') : hide('txtCreditLimit');
}
</script>

initMethod() must be called when the page loads: <body onload="initMethod();">

You also need to add some code to the page load to register the checkChanged with the click event on the checkbox. chkBox.Attributes.Add("onclick", "checkedChanged();");

This then allows the control to be shown and hidden using client side Java script.