a developer's notes – a semi-technical web development BLOG

September 5, 2011

To prevent IE from locking up on long running scripts

Filed under: Javascript / JQuery — Duy Nguyen @ 2:13 pm
Tags: , , , , , , , , ,

To prevent IE from locking up on long running scripts, break out your logic with the Javascript setTimeout method.

I was doing this but it was not working. This was not working because of the way I implemented the looping.

    var size = 100000000; //10,000,000 is ok, 100,000,000 is bad    
    var mystring = "";
    var chunkSize = size / 10000;
    var chunkSizeCounter = 0;

function button2_clientClick() {
        for (var i = 0; i < size; i++) {

        return false;

    function AddToMyString() {
        if (chunkSizeCounter == chunkSize) {
            chunkSizeCounter = 0;
            setTimeout("AddToMyString()", 100);

        mystring = mystring + ",";

But I need to do this. This allowed the browser to continue to loop and process without it locking up. This is because the setTimeOut function runs on a parallel process, which allowed the browser to not “wait” for the processing to complete. Unlike the previous loop, it was taking too long for the For loop to complete. The second implementation allowed the concatString() function to complete on each interval.

    var size = 100000000; //10,000,000 is ok, 100,000,000 is bad    
    var mystring = "";
    var chunkSize = size / 10000;
    var chunkSizeCounter = 0;

    function button2_clientClick() {
        return false;

    function concatString() {
        mystring += ",";
        if (chunkSizeCounter < size)
            window.setTimeout(concatString, 10);

Get a Javascript DOM object from a jQuery object

Filed under: Javascript / JQuery — Duy Nguyen @ 1:49 pm
Tags: , , , , ,

jQuery object is a wrapper around the js DOM object. If you want to get the DOM object from the jQuery object, you should use get() method.

For example, if the jQuery object includes only one DOM object, you can use




However, if you have multiple DOM objects, you can use


var myvar;
myvar= $(‘#<%=selectedProductionIdsHdnVl.ClientID%>‘).get(0);
myvar.value = “b”;

same as

document.getElementById(“<%=selectedProductionIdsHdnVl.ClientID%>“).value = “B”;

This allowed me to use the ASP Hidden field and have the OnValueChanged server side event get fired.

Finding a control in a ASP.Net webpage that uses a Master and Content page

Filed under: ASP.NET — Duy Nguyen @ 1:48 pm
Tags: , , , , , , ,

Finding a control without a Master page can be done with this:


But if you use a Master page with a content page, it won’t work. Try this…

ContentPlaceHolder cph = this.Form.FindControl("ContentPlaceHolder1") as ContentPlaceHolder;

TextBox ctrlInput = (TextBox)cph.FindControl("mycontrol");

Convert comma separated string of ints to int array

Filed under: Javascript / JQuery — Duy Nguyen @ 1:47 pm
Tags: , , , , , , ,

From StackOverflow:

private static int[] StringToIntArray(string myNumbers)
    List<int> myIntegers = new List<int>();
    Array.ForEach(myNumbers.Split(",".ToCharArray()), s =>
        int currentInt;
        if (Int32.TryParse(s, out currentInt))
    return myIntegers.ToArray();

And some code to test:

static void Main(string[] args)
    string myNumbers = "1,2,3,4,5";
    int[] myArray = StringToIntArray(myNumbers);
    Console.WriteLine(myArray.Sum().ToString()); // sum is 15.

    myNumbers = "1,2,3,4,5,6,bad";
    myArray = StringToIntArray(myNumbers);
    Console.WriteLine(myArray.Sum().ToString()); // sum is 21


Mouse or cursor dissapears in VMWare

Filed under: General Tips — Duy Nguyen @ 1:45 pm
Tags: , , , , , , ,

So I don’t know if anyone else every gets this scenario but if you open VMWare and Visual Studio, or any text editor for that matter, mouse over the main text editor window and your mouse disappears.

I found this very annoying.

Control Panel -> Mouse -> Pointers -> set the windows mouse scheme to black IN THE VMWARE SYSTEM not in the host PC.

Comparing two dlls

Filed under: General Tips — Duy Nguyen @ 1:45 pm
Tags: , , ,

You can just use Beyond Compare to compare the binary differences with two dlls but what if you need to find out what the differences are? You can do the following:

To compare two dlls to see if they are different:

1. Use Reflector to extract the contents of the dll into two different directories

2. Use Beyond compare to compare the two folder’s content (and its content)

This way, you can know which file, that is different and what the different is, when comparing two dlls.

Javascript Ajax Calls

Filed under: Javascript / JQuery — Duy Nguyen @ 1:34 pm
Tags: , , ,

You need to add a Web Method attribute on your methods on the code behind. This allows your Javascript aJax calls to these methods.

Disable the ‘Beep” for alert boxes in your VM

Filed under: Daily Computing,General Tips — Duy Nguyen @ 1:32 pm
Tags: , , , ,

If you want to turn off the beep that sounds when you turn on a virtual machine, you can run the following two commands. The first stops the BEEP service and the second disables it on subsequent reboots.

At a command prompt:

net stop beep
sc config beep start= disabled

(Be sure to include a space after the = sign.)

CSS Precedence

Filed under: CSS / Styling — Duy Nguyen @ 1:31 pm
Tags: , , ,

From MSDN:

Precedence of CSS Style Rules:

CSS style rules cascade in the sense that global style rules continue to apply to HTML elements unless local style rules supplant them. In general, local style rules take precedence over general style rules. This means, for example, that a style defined in a STYLE block within a Web page can revise for that one page a Web site style defined in an external CSS style sheet. Similarly, an in-line style defined within a single HTML tag on that page can revise for one line any styles defined for that same element elsewhere.
Portions of global style rules not contradicted by local CSS style rules will continue to apply to HTML elements even after local styles are applied. In the example above, the local CSS styles governing text between <H1> tags replace some of the Web browser’s global style rules for <H1> text (center <H1> text and make it red), but they do not change others (display all <H1> text in a larger font and bolded). Both global and local style rules are applied, in that order, making all the <H1> text on this page display in a larger font and bolded, and centered and red.

Here is a great link about weighing CSS specificity.

Disable the preview of ALL browser tabs in Windows 7

Filed under: Daily Computing — Duy Nguyen @ 1:28 pm
Tags: , , , , ,

To disable the preview of ALL tabs in your web browser in Windows 7,

Check out how to disable it here:


« Previous PageNext Page »

Blog at WordPress.com.