IE6SP2 Download File Dialog Freezes…


crosspost from

Cost me hours to find this! thanks to the person who posted to Channel9!

Just got Hitachi 7K100 (2.5″ HDD, 100GB, 8MB buffer, 7200rpm) and was going to reinstall my host OS on my notebook those 2 days.

after installing XP SP2 and started to install applications and tools, happened after several installations, IE6 just started freezing when trying to download and save files from internet. the download dialog just freeze before pop-up the file-location dialog box for user to choose.

I was originally thinking that maybe some of the installed programs corrupted IE6, so just un-install programs step-by-step reversely to see if IE6 will go back to normal. after several un-installations, all in vain!

later found the post at Channel9 that specify the problem of the cause! really thanks!!!

[via Channel9 Wiki]

Download File Dialog freezes

When the last location you saved to was a network path (eg. \\fileserver\myhomedir) the Download File dialog freezes (IE6SP2). This can be fixed by changing HKCU\Software\Microsoft\Internet Explorer\Download Directory to a local path. This happens to me often after working over a VPN.


This is exactly what happened to me!! after I checked that registry, exactly a network sharing directory on the record. that explain the reason why the download dialog will freeze there, cause the application was trying to locate that sharing directory.

After change the registry entry to a local path, everything back to normal!!! So I have to re-install all the programs that’s been un-installed couple hours ago… Orz…

Technorati Tags: microsoft , internet explorerbug


Escape single quotation mark in sql query…


crosspost from

just a reminder of forming a sql query.

for concating strings in different databases, refer to my post here.

for concatenation, MS SQL uses ” + ” operator , Oracle uses ” || ” operator (as well as MySql uses function CONCAT() ) . so if one is designing a Data Repository using Repository Pattern, one may need to process this in repository level, which like providing a function for other code to concate strings in forming a query.

fortunately, for escaping single quotation mark in a query , it’s the same as in MsSql and Oracle , they both used 2 single quotation marks to escape single quotation mark in a single-quotation-mark quoted string. (eg: for a string like o’connell to put in a query, it’s ‘o”connell’ , ” ‘ ‘ ” is escaped and represents ” ‘ “).

by the way, as NHibernate is just transforming object propertires in to real database field names, those rules above also apply to HQL query. also true if one is using escape chars in a “like” search (eg: select .. from class1 cls where cls.prop1 like ‘%My\\_Name%’ escape ‘\\’ ), the translation to real sql query both for mssql and oracle is tested without problems. 

Technorati Tags: hibernate , nhibernate , orm , database , programming


quotation marks and javascript…


crosspost from

It’s all about Javascript when dealing with AJAX components…

When one is writing client functions, and needs to attach to event handlers, like:

<input type=”button” name=”aName” id=”aID” value=”Press Me!” onclick=” func1(); “>

It’s simple when just calling a function to do things. Alternatively, one can also write multiple statements inside the onclick string:

onclick=” var str1=’a string’; alert(str1); “

What about if one is going to dynamically generate a control (via string) and put it in some other controls innerHTML, like this:

var strshowmsg = “Show me as a string”;
var strtrouble = “Show me as a string with \” exist also got ‘ exist!!!”;
var strcontrol1 = “<input type=\”button\” id=\”button1\” name=\”button1\” value=\”Press Me!\” onclick=\”var str1='” + strshowmsg + “‘; alert(str1);\”>”;
document.getElementById(strASpanTagID).innerHTML = strcontrol1;

It should be ok if the first string is going to output, but it should got script error when trying to show the second string because quotation marks crash pairing of strings.

strtrouble string variable often happened when strings are coming from a database or some user input. one never know what will be coming in (except telling user that only single quotation marks are allowed or what). in order to allow anything to be able to put in this kind of application, there is one way to do it.

var strcontrol1 = “<input type=\”button\” id=\”button1\” name=\”button1\” value=\”Press Me!\” onclick=\”eval(unescape(‘” + escape(“var str1=\”” + strshowmsg.replace(“\””,”\\\”) + “\”; alert(str1);”) + “‘));\”>”;

The idea is to use eval to wrap whole javascript in a string and using escape / unescape to url encode the whole string to prevent any special chars, finally, explicitly escape double quotation marks inside the string coming from a variable output (from database, or user input) to ensure the whole escaped javascript statements are in the right way to output (since here using double quotation marks to wrap strings…).

Technorati Tags: , programmingajaxjavascript


My turn to have VS.NET 2003 tell me "failure occurred while attempting to start compilation" …


crosspost from


busy on writing my code and get this “failure occurred while attempting to start compilation” from 2003 , happened without a reason.

a search to Google found the reason of the cause (likely) [I am not lonely… Orz]. Seems too many projects in one solution will cause this error (I got 17 projects in a solution currently). some one got 67 projects provided a fix to solve this (thanks to Jeffrey to point out the link), but didn’t work out to my situation (close, delete all pdb file by using “del *.pdb /s”, open and compile again) .

Finally I got my situation solved by:

  1. Minimize projects in a solution to 13 projects.

  2. Close VS.NET 2003

  3. Delete all .pdb files in bin dir.

  4. Delete all .dll files in bin dir.

  5. Open VS.NET 2003 and compile again.

I know! this will be my last project using VS.NET 2003, will switch to VS.NET 2005 in next project.

… Or I know!! I’ll start learning using NAnt..

Technorati Tags: , programmingvisualstudio


Setting up TTL for DNS records…


crosspost from

The follow-up of my company’s SORB database issue (here and here).

I’ve asked my ISP to manually extend our company’s rDNS record TTL to 86400 and now it passed the test from SORBS database.

just did a test trying to excluding the IP from the database and still get rejected. reason:

Checking MX’s for…
Rejecting MX 10 [TTL 13135] (TTL too short)

No acceptable MX records found for

SORBS really did seriously checking to a dynamic IP !!! Orz

How to manually set DNS records TTL? by refering articles here and here:

; MX record Format:
; name          ttl  class  rr  pref     name          IN    MX   10

; A record Format:
; name  ttl  class  rr        ip
joe           IN     A

$TTL 2d ; zone default = 2 days or 172800 seconds

just set ttl time between name and class will do. or just set default TTL for the whole domain.

Technorati Tags: email , smtp , sorbs , rdns , hinet , reverse dns – initial values validation while page load or post back…


crosspost from

It’s mostly required to do the initial values validation while an application start, no matter it’s a winform or webform, a page taking values from query string or a web control taking values from attributes.

Lessons learned while doing my project, while doing a web user control. if main page will do many initial operations against a child web user control. the child web user control better doing it’s all variable initiation at Page_Init event instead of a Page_Load. remembered the sequence of page event occurrence: Page_Init -> Load ViewState -> Page Load -> PreRender -> Render -> Page_Unload , till here the server side operation completed and web server send the renderred page to the client, this is the start time client javascript code take place. For composited control tree, started from page, the event occurrence start from root (the page), then followed by leaf controls. thus if in page’s page_load there are many function calls to child controls, it might not get ready for control’s initial value prepared for the main page or its own functions. therefore it should be better to put initial value setting and validation during page_init event, instead of page_load event.

It’s common for page to take parameters from query string during post backs, also normal for web user control to get parameters from attributes specified from page or other controls. It would be a good practice to always validate those values before start processing logics.

for parameters there will always some values (mostly string values) pre-defined for user to specify. normally some integers, or strings like “true” or “false” or others custimized. by doing a initial value validation while page_init make sure the control gor the correct value and reduce the error handling inside logics. normally the validation code would like the following:

if (strValue1 == null) strValue1 = “”; // be sure always check null.
if (strValue1.ToLower() != “true” && strValue1.ToLower() != “false”) strValue1 = “false”;
if (strLevel == null) strLevel = “”;
if (strLevel.ToLower() != “low” && strLevel.ToLower() != “middle” && strLevel.ToLower() != “high”) strLevel = “middle”;

this will get little lousy if a parameter got too many options to set.

null is always the thing needs to be checked, since one may not able to know if certain variable was initialized or not. make sure at least the string is not null, then for those lousy if statement, just found a way to reduce it, by using string comparison:

if (strLevel == null) strLevel = “”; // make sure it’s not null to prevent runtime error
if (“_low,middle,high”.IndexOf(strLevel.ToLower()) < 1) strLevel = “middle”;
if (strValue2 == null) strValue2 = “”;
if (“_1_2_3_4_5_6_”.IndexOf(strValue2) < 1) strValue2 = “1”; // check if the value is 1~6.

using IndexOf to check the occurence of preferred values, reduce the if (…) …; code needed. some notices of this are:

  • strLevel can not be null or it will cause run-time error. so check the null first.

  • Astring.IndexOf(“”) always return 0, which make sense anyway. this will be the same index value of first char of the string to be compared. therefore do not put comparing string from first position. instead, putting them started from the second char by putting a space or anything in the first char. and do the compared value that’s ” < 1 ” instead of ” < 0″ .

  • for the concern of matching the wrong value wanted, eg intened to matching “1” inside the string “_123456” , but a value “12” comes in, it will match ( index at 1 ) but still got the wrong value required. put seperators between matching values should solve this (eg “_1_2_3_4_5_6_”).

  • RegularExpression class should be the right one to choose for this operation, but it still seems too lousy to me.

this should reduce some amount of coding, also easy to understand the intension. and page or control will got correct and required values while processing logics thus reduce validation code needed.

Technorati Tags: , programming


Javascript – Select / UnSelect All checkbox…


crosspost from

Often used tricks on HTML / Javascript design to provide a select all / unselect all checkbox somewhere to make user a better UI experience.

Google search got many result about this, since it’s already old tricks that’s often used in many websites. but sometimes it’s easy to forget about how to quickly write one in hand, I found this example that’s simple and quick to understand and pick up.

Technorati Tags: , programming , javascript 


Sync your CVS source trees with WinMerge…


crosspost from

Since I am not in a Unix / Linux world (yet) , gotta find my own way and tools to deal with such problems, in a windows way.

Situation as follows:

I kept a source tree in my own development VM to keep source integrated and shared between my team members, in a local LAN, mostly at on-site environment that might block various internet access ports (SSH, port 22, etc). That means I am managing a CVS server in my development VM and team members just submit code they modified and also update code others submitted (make sure you are using secure protocols to send your source around network).

There is the main source CVS repository in my company office, in some situations the customer site may also got a source tree for vendors to submit into. so there will be problems syncing the local cvs source tree (in my VM) and external source tree (main office or customer site).

Since “CVS” folders should not be touched while sync (contain version information to compare with), and the destination (main office, etc) may contain files that already deleted that need to clear, there should be something that need to be careful in order to prevent massing up my updated source which might spend couple days developed.

A quick way to should be just using WinCVS to change the CVSRoot of  master local copy from local to the destination, then just do a update->add content->commit to update the destination. but I do think that is too risky cause a miss could mass up my local copy no matter it’s the miss made by myself or by any CVS client.

So I am developing my own safer way. comparing files myself using tools. my solution as follows:

First create a temp directory, checking out local copies both from local cvs repository and the destination cvs one (either using WinCVS or TortoiseCVS, I found it easier using TortoiseCVS), so I got 2 directories with different CVS meta info (the CVS folders contains different info for 2 cvs resposotories). next, using a batch file xcopy with exclude options to xcopy all the things from checked-out-ed local copy to destination one, EXCLUDING all CVS folders. now I got identical files in both directories without affecting cvs meta data. the latest thing should be remove deleted files in destination. for this I used WinMerge to help me. WinMerge not only help A LOT on comparing conflict source files, but also capable to compare 2 directories with all the differences. check WinMerge website for usage and you’ll know what I am talking about. it also integrated very well with TortoiseCVS. so I can use WinMerge to find those files that I was deleted in local but still left in the destination. then it’s easy for destination local copy to just do a remove of those files, and finally, an add content -> update -> commit should check-in all the source to destination cvs repository that’s identically the same as my local source tree, without affecting my real working source.

I shall try out using a SubVersion repository in my next project.

Technorati Tags: windows , cvs , cvsnt 


Javascript – Casting to integer on arithmetic division…


crosspost from

Been rushing on my working project and coding a lot Ajax using lately. Had a lot of  re-practice back to javascript. here is a quick pick of one of them.

As Javascript been a weak-typed language, sometimes it’s not able to cast a variable from one type to another. as in arithmetic division, if one wants to output an integer instead of a double or else, here is a way learned from this article that’s useful:

a = ( b / c ) | 0

by using a bitwise OR operation to cast a float / double back to an integer, to have a way casting some numeric values back to desired form.

also there is a nice Javascript language reference I dig a lot during this coding. thanks for the help!

Technorati Tags: , programming , javascript