# Saturday, February 23, 2008

I delivered the web security presentation yesterday for my customer.  This is the same presentation I delivered as part of the DevCares event last week.  It went much better due to the fact that I secured a much better laptop for the presentation.  

The presentation materials are available here.

Saturday, February 23, 2008 2:30:46 PM (GMT Standard Time, UTC+00:00)
# Thursday, February 21, 2008

Scott Mitchell has an excellent article on 4GuysFromRolla.com about how to use ASP.Net to prompt a user to save changes before leaving a page.  It is part of a series he wrote back in 2004 but it is still relevant today.  The only change you should make today is that he calls methods of the Page class (IsStartupScriptRegistered, RegisterClientScriptBlock, RegisterArrayDeclaration) and these methods are depcrecated and replaced by the same methods in the Page.ClientScript class.

Scott's code initializes a client-side array with a list of inputs to monitor and the initial value of each input.  He then uses the onbeforeunload event to check if the data in any of these inputs has changed and displays a confirmation prompt if any data hase changed.  This event fires even if the user attempts to exit the form by closing the browser or clicking the brower's 'Back' button.

I liked Scott's approach so much that I took his public methods and moved them into a base class that inherits from System.Web.UI.Page and I inherit all my web pages from this class.  Now in each Page_Load, I can call methods of the base class to register controls that, if changed, will mark page data as dirty and prompt the user when he attempts to navigate away without saving.

I noticed that the "initial state" of controls were reset whenever a postback occurred, so I created a method "MarkDataAsDirty" that could be called when a control's "autopostback" fired but when the user is not finished entering data.  This sets a hidden form on the client that is checked in the onbeforeunload method to determine if data has changed.

I also made the methods public so they could be accessible to any user controls dropped on a page.  And I created the utility method RegisterForConfirmUnsavedChanges that registers the most common controls on the page using Scott's original methods.

I've included a sample ASP.NET web site in which every page inherits from a base page and methods of that base class are called to implement this functionality.

 

ConfirmSaveSite1.zip (9.51 KB)
Thursday, February 21, 2008 4:15:33 PM (GMT Standard Time, UTC+00:00)

Tonight's lunar eclipse was impressive.  I think I saw a full lunar eclipse when I was a boy but I don't remember it well.  This time I saw the moon with the full shadow of the Earth upon its face.  As I had heard, the light around the Earth's atmosphere cast a blood-led glow on the moon, giving it an eerie quality.  I managed a couple of photos despite not having a handy tripod.

 

Photo by David Giard

 

Thursday, February 21, 2008 3:18:54 AM (GMT Standard Time, UTC+00:00)
# Wednesday, February 20, 2008

My son's high school basketball team won again tonight.  In the first half, they were thoroughly outplayed and trailed by as many as 24 points.  But they chipped away at the lead and ended up winning by 4.  It was a big win, not because they beat a good team (they did) but becuase it was the last game of the year and they finished the season 20-0.  It was the first undefeated team at his school in 35 years.

The state tournament starts Monday in Dexter. 

Nick and Dave

You can view photos of the final game (along with a kick-ass soundtrack) below.

Wednesday, February 20, 2008 3:27:42 AM (GMT Standard Time, UTC+00:00)
# Sunday, February 17, 2008

The DevCares event went pretty well.  Over 40 people attended.  I didn't have a decent laptop to use and I ended up borrowing one from a friend but it was not nearly powerful enough to run all the demos on the Virtual PC.  This detracted from the presentation.

I will be delivering this same presentation for my customer next Friday and I have already requested better hardware.     

I got some help from Mike Wood, who delivered this presentation the week before in Cincinnati.

You can view the materials at www.davidgiard.com/DevCares.

 

Sunday, February 17, 2008 4:47:16 PM (GMT Standard Time, UTC+00:00)
# Thursday, February 14, 2008

I'll be speaking at the Microsoft DevCares even tomorrow afternoon in Southfiled, MI.

The topics are:

  • Securing your web site from hackers
  • Microsoft Visual Studio Tools for Office.

There is still time to register at http://www.devcares.com

 

Thursday, February 14, 2008 4:45:15 PM (GMT Standard Time, UTC+00:00)