Most of this week I was too busy with other things at work to attack the .Net migration again. When I had a chance, I opted to go for the portlet that collects user feedback and stuffs it in a database. Still one page like the previous one, but at least it was interactive. I had my first real encounter, or should I say collision, with the page lifecycle. I added a RequiredField Validator for the textarea in web matrix, then a simple branch in Page_Load that checks IsPostBack and IsValid. Task done, right? Ohhh no. If it was a Perl CGI script, then that strategy would have worked. Not so here, because the Page_Load event comes before validation happens. That means, Page_Load cannot check IsValid! I know that the "button click" event never really "fires", because on the Web all that happens is documents zipping back and forth over HTTP, browser to server. The game is pretending that the user just clicked a button, and the server is handling that event, rather than receiving a POST. It's an interesting conceptual shift, and I imagine it will feel more natural in visual studio than in sharpdevelop/web matrix. Anyway, I just moved the code from Page_Load to the onClick handler, and that was that.
The real letdown in this round was saving the data out to the database, over the Light/Dark boundary, as our main database is not Sql Server or (heaven forbid) Access. The feedback goes in a CLOB in our database. This turned out to be a point at which my meager .Net experience matched my experience in Java: CLOBs are a pain in the cojones to work with. (The real blame in both cases is, of course, on the database driver implementations and not the platforms). Should have used a varchar, I imagine, but can't change it now. Tried it one way, got a mysterious and unhelpful error message from the driver, then tried it a different way. Joy, another unhelpful error message. Repeat ad nauseum. Finally, after admitting defeat through switching from the database-specific provider classes to the more generic OleDb family, it worked. Have I mentioned that a CLOB should be a last resort data type? We don't need to give our users the ability to spew a novella of bile at us, a short story will do.
The sun still rises in the east and sets in the west, no matter where you live, unless you're in a polar region that has time periods of darkness. Database vendors tend to focus their best driver efforts on whatever platform they see as advantagous. In any case, CLOBs alternately blow and suck. The Sith and the Jedi are similar in almost every way, including their quest for greater power.