When I started this job, one of my first projects was to write a web-based incident tracking system. I did the first version in PHP and MySQL, because this is what I knew, and I needed to get something running quickly. But in order to put the system on the hospital’s intranet, I needed to convert it to IIS, C#, and SQL.
It was a switch, but I gotta tell you, I love Visual Studio. I edit everything in one place, and I can test changes to the site in about five seconds. The Studio doesn’t know too much about JavaScript, but it knows everything about CSS, HTML, and C#, and the IntelliSense cues are extremely useful. Still, there were some irritants. They offer a million widgets for your pages (from the toolbox), but they all use this mysterious runat=”server”, and generate HTML that really didn’t look like what I was used to. Since I had already decided that I didn’t want to lock myself into Microsoft, I adopted a couple of rules:
Let JavaScript control changes to the display. In the time management site I wrote about earlier, parts of the page were written by JavaScript, part by PHP, and sometimes it was the same part, with redundant coding.
Limit the server side code to providing raw data (see rule one). Almost all of the C# code is called via Ajax – I send out a request for data, and get some JSON back. If at some point I have to move the site from C#/SQL back to PHP/MySQL, it won’t be a major undertaking.
Keep the formatting separate from the code. This really has nothing to do with the Studio, but it’s worth remembering. If I want to change how the page looks, I change the CSS.
In the examples section of the site, I’ve included the code for one page from the tracking system, to show how this works. The example is primarily about the JavaScript Ajax/C# interaction for retrieving data. I’ve become a big fan of Ajax, primarily because it lets me do so much more without constantly interrupting the user with a page refresh. It works almost (we’re not there yet) as smoothly as a desktop application.
There are a few other tidbits in the example, like how to convert a Word document to a pdf file using C#.
[ 1 comment ] ( 20 views ) | permalink

Calendar



