Thursday, January 19, 2006

ASP.NET 2.0 Changes Everything for TOA

I'm going to document the things I'm implementing, experimenting, designing, coding to the underbelly of TOA. Hopefully people will notice nothing, as I've implemented these changes in such a way as to recreate the current interface.

List of Features
  • Send Email using System.Net.Mail
    • This took me a week to figure out and get working. 2.0 deprecated (made obsolete) the use of System.Web.Mail class to send mail. While the code still works, it is longer supported, less secure and less feature rich. The test were conducted in a folder called mailtest on TOADev. The web form originally had the script included in the page. Once I got it working, I converted it to a code-behind class. The mailform.aspx page is just the web form now. If you look at the VBscript, you can see it simply opens up a mail message object. Then I fill in basic part of the message, the From, To, Subject and Body from the web form. Originally, I had these hard coded. Then I create a new object to open up the smtp connection. You can see that the server settings are not hard coded here. They use the default settings, which I set in the web.config file. Then send it. In the near future I want to add Attachment capabilities. Also add validity checks to this code, like an invalid or missing email address.
  • SMTP Services, open relay services, watch out for McAfee
    • Early in the above testing process, I was getting a lot of exceptions (errors). The error messages are vague and have to be mapped to settings and thus there is a certain about of interpretation on what they might mean. Early errors were that the code was incorrect. Next I got socket connection errors. This is because SMTP/IIS was not installed on my local machine. Once installed (this is what took a week) using the XP Service Pack 2 CD, it totally worked. Problems occurred when I tried it on the Itdev server. Error checking means I have to wait until Ray is around to log me in to play with the configurations. Since I had a similar set up on my machine, I knew what to look for. But it still didn't work. I was getting a different exception error: software on machine is closing connection. Some googling later, I figured out that McAfee was running on the server, and had closed port 25 because of some mass mailing setting.
  • MasterPages with .net2
    • These are basically server-side templates. I tested this with the Intro Module. Using this structure helped me to see clearly the structure of the site, and keep things much cleaner. All files associated with the MasterPage template are in one folder. The content reside inside tags called ContentPlaceHolders. It may seem overly complicated, but with 11,000 web pages, this more tractable.
  • Nested MasterPages with .n2
    • But then I had a problem, some pages have menus and a back navigation link, while others don't Trying to avoid redundancy is to whole point of doing this. It turns out that Master Pages can be nested, a "sub" master can call a master while a content can call the master directly. This is what I needed, index pages call the master, whereas module pages call the ModulePage master, which in turns call the Master. In this module page is when I add the menus and the BackNav. I still need to see if this is going to work with the rest of the site at different level of folder hierarchy. Since this is more of an object-oriented model, the path dependencies should matter much less.
  • User Controls with .n2
    • These are .net version of server side includes, in other words code snippets of html markup pasted when the page is called. This was the first thing I adopted from 2.0. I had Xin convert some of the courses using an elaborate use of User Controls. While these were a marginal advance over previous designs, we had to make a different control for each level of the hierarchy. It was not a scalable solution. When I learned about MasterPage, I adopted it quickly.
  • Code Behind
    • I'm still learning how to do this. Basically what this allows me to do is to have the VB script code in a separate file from the HTML markup. This in theory should allow for reusable set of code. Code Behind structure is more complicated that inline code, it still you have to structure the code inside namespaces and class, and label classes and subroutines as public, protected or private. I'm hoping we can apply to especially to Charlie's data management consoles.
  • CSS Dropdown menus (Sons of Suckerfish, HTML Dog)
    • We had been using Milonix freeware Javascript menus. The code worked well, but was ccumbersome in linking to external js files. 'Paths are my enemy.' They had to go, plus I read that css driven menus were lighter in code weight and markup. I use the popular Sons of Suckerfish code. It's modified in that I had to get the menu to "float" over the banner bar. The use of position:absolute broke some of the logic. But I managed to get a functional equivalent working. One benefit is that the menu content file is human-readable, it's just an unordered list. My implemenation is less stylish. There are no drop shadows. Also the menu feels more like buttons than light floating menus. Oh well, I don't think people will notice too much. By the way, IE behaves quite differently from Firefox. The hover.js file is minimal but necessary.

No comments: