Over the past week I taught two .NET classes in hurricane-struck Baton Rouge, Louisiana. I flew into New Orleans, arriving Saturday night. Instead of hitting the hotel I drove directly to the French Quarter to see what was still standing after the storm. On the way it was interesting to see an occasional boat resting on the roadside. Upon arriving in the historic downtown to my delight all of my favorite places looked fairly intact. Even in the surrounding areas the classic century-old wooden houses on the parade routes were in good order. There were signs blown over and a broken window here or there, but altogether at least physically the Quarter was still there. But kinda eerie to see almost nobody out on a Saturday night.
On Sunday I got to see the absolute war zone which is the 9th ward. Went out to church in the area and talked with lots of the locals, and their stories are heartbreaking and remarkable, and their outlook is full of hope. Some are just getting electricity back. Many living with friends and relatives. Of course extreme loss, but through it all people are smiling and coping as they can. On virtually every corner there's a fast food place with a "now hiring - $10 per hour" sign. A few are $12 an hour. On top of $22K to $24K a year to flip burgers, in the picture at the right is Burger King's offer - an automatic $6000 a year bonus. Businesses are ready to roll again, but the people aren't back yet. Probably many of them won't ever be back.
There are cars and trucks moored on the roadside and all over, with telltale lines of dirt marking how high the water level had been. Virtually everything in that part of town had been submerged. For the rare home that sustained no external damage, certainly on the inside all the drywall will need to be gutted and replaced. And on each street corner there were stacks of disposed furniture and building materials. In the worst-hit areas it was uninhabitable, and nearby there was only about one home in five currently inhabited, with many cars of friends and relatives clustered around.
After that brief glimpse into the worst tragedy I've ever seen first-hand, I retreated back to the high ground of Vieux Carre to see what things were like there in the daytime. Only about a quarter of the people you would usually see in the Quarter on a weekend were there, but still some tourists and street vendors about. I ate at the Palace Cafe, where the first floor was filled to capacity. This was the first day they had brought back their entire brunch menu, and the trout amandine was excellent.
After looking around a little more at the humbling scene it was getting into the late afternoon, and time to prepare to teach the class in Baton Rouge. In my planning for hotels prior to leaving Phoenix I hadn't found a room at a reasonable rate for Sunday night, so I decided to pack my favorite sleeping bag and stay at beautiful Tickfaw state park about 20 miles East of Baton Rouge. It has only recently reopened, so many of the displaced locals scrambling to find a room are unaware of this availability. I figure it's a nice setting in the middle of nature and comes with a hot shower in the morning, so quite a bargain at only $12 for the night. I bought a tent at the local Wal-Mart and went out to enjoy. The surroundings were so peaceful compared with the upheaval I had just witnessed.
Lots of businesses and restaurants from New Orleans have now reopened in Baton Rouge. On Tuesday I ate at one, a truly great century-old restaurant from the French Quarter, Galatoire's. Very nice meal, but arriving without a reservation meant I sat at the bar for about an hour waiting for a table. That was okay, it gave me time to open the laptop and write some code to be used for the next day's class. The food was good and the place was packed, so they're definitely ready for the planned expansion of their dining room coming next month.
Speaking of class I had only two students -- and both were actually in my previous Reporting Services class that I had taught in Baton Rouge back in May. One was battling a Javascript issue with a calendar in an application that had been converted from ASP.NET 1.1 to 2.0. Somehow a hidden field showing the currently selected date had gone missing in the transition, so we wrote a server control that extends the existing System.Web.UI.WebControls.Calendar class to render that along with the calendar as raw HTML. Here's the code we had placed in a file called Controls.vb in the App_Code directory:
Namespace
Controls Public Class OurCalendar Inherits Calendar ' If you want the calendar to default to having today's date selected:
'Public Sub New() ' MyBase.New()
' Me.SelectedDate = DateTime.Today 'End Sub Public Overrides Sub RenderControl(ByVal htw As HtmlTextWriter)
MyBase.RenderControl(htw)
' After rendering the calendar, put in a hidden field with the date
' for the Javascript to reference
htw.Write("<input name=""datechosen"" id=""datechosen"" type=""hidden"" " & _ "value=""" & Me.SelectedDate.ToShortDateString() & """ />") End Sub End ClassEnd
Namespace
The name “datechosen“ is what the Javascript expects to see, so that's why it's hard-coded. Note that if you were to place two or more of these calendars on the page then there would be multiple controls with the same name, potentially giving grief.
The class must be in a namespace in order to be accessible from an ASP.NET page, the namespace above being “Controls“. Here now are the various lines to modify in an .ASPX file that uses the control, starting with the @Register directive to add at the top:
<%
@ Register TagPrefix="cntl" Namespace="Controls" %>
And then in the <form> element of the page we originally had this control, being dragged in straight from the Toolbox:
<
asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
We swapped that line out with this code to instead reference our new calendar:
<
cntl:OurCalendar ID="Calendar1" runat="server"></cntl:OurCalendar>
Note the @Register directive. The TagPrefix attribute, as its name implies, is the prefix of the custom element being used. In order for this very simple form of @Register to work, the source code for the control has to be found in the App_Code folder or be in the same project as the .ASPX page. Otherwise if it is in a .DLL being referenced then @Register needs to include the assembly attribute to call out the assembly which has the class that defines the server control.
My other student works in the evenings and weekends as a volunteer at a fire department, and is interested in creating a website to track the members of the stations and squads around town. The only problem is that he can not use a database to store any login data, and he is limited to using ASP.NET v1.1 so all the login routines are from scratch! Leveraging the DataSet's WriteXml() and ReadXml() methods, we were able to get the job done pretty easily. We wrote a generic class called PageBase that extends from System.Web.UI.Page whose lot in life is solely to read in the contents of an XML file into a common dataset called _ds. Then each of the pages extend from it in order to use the contents of that DataSet. Both a simple login and registration page in the project then make use of PageBase. Here it is for your experimentation:
Another topic that came up during class was about performance differences between SqlDataReader, SqlDataAdapter, and SqlDataSource. So in my next post I'll have a rundown of the results, as well as some sample AJAX code using 2.0. Also more pictures, and adventures in this life of this part-time contract trainer. But for now it's time to get back to what I now do three weeks out of the month: writing code for my friend Scott's company myKB.com!