Tuesday, November 21, 2006

Modal Dialogs in Web

It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter.
(Nathaniel S Borenstein)

Modal dialogs are pretty common in WIN environment. These are used when u want some user input before u proceed with the main flow of the application. The basic difference between a normal dialog box and a modal dialog is that u cant do any operation in the window that opened the modal window till u complete (or close) the modal window.  There's a lot of debate on when to use modal dialogs and I found the first couple of paras of this article
useful.

As a POC for our new project which is to port a complete reporting application from WIN to WEB me & one of my colleagus got the chance to try out this modal dialog in Web.  In IE you have window.showModalDialog('url','windowName','windowProps') java script function which gives u a modal window. But in Firefox this does NOT work. You can partially achieve the modal behaviour by giving a third param to the window.open function modal=yes. This will keep the focus on the new dialog but user can still interact with the underneath parent window. Check out this blog entry by David Kasper for a detailed discussion.

There were some other requirements with this modal dialog.
1. Make sure it pops automatically after a certain postback event.
2. To be able to update backend domain objects from the modal dialog it self.
3. To inform the parent window about the operation that was performed in the modal dialog.

Since we're using ASP.Net 2.0 here's a briefing about how to do above using ASP.Net 2.0.

Popping Back automatically upon postback
You just have to include the modal dialog showing function string as a start up script using ClientScript.RegisterStartupScript function. (status = window.showModalDialog(url,'DlgName');)

Updating bkend domain objects
This was a pretty hard thing to do since the calling of the usual __postback javascript function didn't work as expected.

Communicating with the parent
This is again somewhat tricky. Specially if u've done this seamlessly with multiple browser windows, u r in for a surprise here.  Unlike with multiple browser windows u cant pass multiple value from child to parent using window.opener.... Instead you'll solely has to rely on window.returnValue to send something back to the parent. The hack of passing multiple values is to set this with an array and breaking down that array in the parent.

This is the first time I'm in a web project in my breif programming career and things seems interesting as ever.

Monday, November 13, 2006

What makes people happy...

The main tenets of modern economics is that "People act in their self interest most of the time and that they usually know what exactly their self interest is". But do they really know it? Most will say that Health, Family, Childern or Money :) would bring happiness. But how do u know?

I always wondered whether our pets are happier than us? They seem to be laid back and happy most of the time anyway :).






A group of economist and psychologists have started experiments to check exactly what makes humans happy and its impact to the economy. Check this article at newyorker.com to find out more.

Saturday, November 11, 2006

Why we are poor and keep getting poorer

As a country 'Sri Lanka' is poor. And people come up with so many different arguments as to why it is so. For so many years there were so many theories and attempts but we are still laggning far far behind in the development race.

An article I found in the reason.com web site has tried to explain why poor countries are kept to be poor taking Cameroon as an example. It has a lot of similarities to Sri Lanka.

Enjoy!!!

Tuesday, November 07, 2006

DB Locking Vs Versioning

How a database server handles concurrency is a great deal of interest to any application. Historically SQL Server has been lagging behind DBMSs like Oracle for their rather legacy way of handling this with multiple levels of locking mechanisms. By comparison most other DBMS adapt a versioning mechanism. You can read about both in this excellent article.

But SQL 2005 has put a step forward and introduced versioning. To check out all the levels of versioning refer MSDN. What we have used in our project is 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITED' which is the lowest level of versioning giving the maximum performance and the maximum risk of fetching invalidated data in to the application. We are working on a reporting application where the changes to the data is much less frequent compared to the reporting of the data and this was very much acceptable.

Monday, November 06, 2006

Windows Live Editor

Wow!!!! I'm using the windows live editor to update this blog entry. I know that offline blog editors have been around for sometime now, but when Microsoft offeres a product which it claims to work with other 3rd party people u gotta try it out RIGHT?

After 30 mins of scrambling here and there I was able to configure it. It supports over 10 blog sites beside its own Live Space.

Download it here and just check it out.