Teach kids to love, not to kill!

Below explains why Jimmy Kimmel has a big evil in his heart.
----------------------------------------------------------
What a Journey
Chunyan Li, Ph.D.
11/8/2013

Dear all,

How long does it take us to get here today? One hour? Two hours? For me, it is 20 years! 20 years ago I arrived at this land of the free, full of ideals, perhaps from listening too much to radio Voice of America.  20 years later my sons join me to protest against ABC's spreading of racial hatred and violence. What is wrong with this picture?

I ask my teenage son whether we should just treat "killing Chinese" as a joke. He said this demonstrates what the society and media had been feeding our young kids. My heart sank. Is America moving forward or backward?

Now I ask again: How long does it take us to get here? I don't know about you, but the last 20 days seem longer than my 20 years. Those of us who stand here today must have been reading, writing, arguing, and agonizing over confusing pieces of reports and commentaries. And we ask ourselves, are we being unreasonable? Is our English that bad that we don't know what an apology is? 

On 10/28, the night of our first protest, Mr. Kimmel said, "today is a weird day...I am sorry if I offended anyone." I ask ABC, who is the weird one? Who truly apologizes if he doesn't even say sorry for what? Sorry to whom? To the Chinese whose sense of tranquility is forever disturbed? To our kids whom we try so hard to shield from pain and harm?  To the schools that teach kids the spirit of Dr. Martin Luther King? ABC, do you call that an apology? 

In a letter to 80-20, ABC still claims it only entertains. Why is joking about killing Chinese so entertaining? Is it because we are always so nice? My friend's sweet 11-year old wants to write on his poster, "do not take advantage of us." I first didn't understand, then found out he meant "don't take advantage of us because we are nice." That broke my heart!!! ABC and Mr. Kimmel, we hold you accountable for taking away our children's precious sense of security. And we hold you accountable for sowing the seeds of hatred in other children's minds.

On 10/29, Mr. Kimmel even resorted to the ridiculous notion of cultural difference. I ask him, what cultural difference do you mean? A culture of hard work, respect, harmony versus a culture of violence and racial hatred? Then I admit there is an unbridgeable difference between Kimmel and us. We know what's right, what's wrong. And we know what humor is too! Yet we have no tolerance of your malicious joke, subsequent insult on air, then the absurd reference to culture. This only proves Mr. Kimmel you are unfit to be a public figure. 

ABC, stop blaming cultural differences for your own mistakes! Except for Native Americans, all are immigrants with unique traits. Yet we share the basic value of human dignity. Stop magnifying the differences in skin colors, or accents!

I ask a third time, how long does it take us to get here? Our friends started telling us there is another written apology somewhere. Who in real life is given so many third chances? Yet I ponder, are we asking too much? I discovered to my dismay that in that written letter, Mr. Kimmel is still hiding behind the 6-year old. Come on Mr. Kimmel, you think our anger is on a 6-year old? Our anger is on your malicious question "Should we allow the Chinese to live?" Our anger is on your subsequent arrogant ridicule. Our rage is on ABC for not letting the public know the truth of these so called apologies. 

America is the home of the brave. ABC, show our kids you have the courage of admitting wrong doing, show our kids you have the guts to take responsibility by dismissing Mr. Kimmel. Show us you have the resolve to institute procedures to prevent future incidences. ABC, do NOT hide behind a 6-year old!  Show us what a major network can do to right its wrong!

Twenty years, twenty days. Life, liberty and the pursuit of happiness. Who doesn't want to be happy? But without life, what is liberty? Without liberty, what is happiness? Let's join hands in our pursuit of human dignity. 

Teach kids to love, not to kill!

jQuery UI Dialog and ASP.NET PostBack

I am replacing MS ModalPopup with jQuery UI Dialog in my ASP.NET projects recently. It seemed easy in the beginning, but it turned out I had to search solutions on Internet.

Let me use a sample to explain what should be done to make jQuery Dialog work in ASP.NET page. The web page has input fields (Name and Address) and buttons (Save and Clone):


All the fields and buttons are inside an UpdatePanel. When Clone button is clicked, a Dialog will be displayed:


The Submit button is supposed to postback user's selection.

The JavaScript is like below:

        $(function () {
            CreateCloneDialog();
        });

        function CreateCloneDialog() {
            // Clone dialog
            $('#pnlSectionsToClone').dialog(
              { autoOpen: false,
                modal: true,
                width: 'auto',
                height: 'auto',
                resizable: false
            });
        }

        function DisplayCloneDialog() {
            // Open the dialog
            $('#pnlSectionsToClone').dialog('open');
        }

The pnlSectionsToClone is the content panel of the Dialog. When Clone button is clicked, function DisplayCloneDialog() will be called. Everything seems simple so far. But the page had these problems:

1. When the page is loaded and Clone button is clicked, the Dialog is displayed with no problem. But once the Save button is clicked, the Clone button will throw this exception (in Firefox) and no Dialog is displayed:

Error: cannot call methods on dialog prior to initialization; attempted to call method 'open'

The reason of the exception is: after Save button is clicked, the UpdatePanel receives HTTP response and updates DOM in browser. The Dialog object in CreateCloneDialog() is removed from DOM at this time. The following 'open' will fail.

The solution for this issue is to call CreateCloneDialog() after each postback:

        $(function () {
            CreateCloneDialog();
            Sys.WebForms.PageRequestManager.getInstance()
                        .add_endRequest(CreateCloneDialog);
        });

2. When the Dialog is displayed, the Submit button does NOT postback.

The reason for this issue is: the dialog object is added to the Document in DOM, not inside Form tag. You can see that clearly in Firebug:


To move the dialog object into Form tag for postback, you need add one extra line of code to function CreateCloneDialog():

        function CreateCloneDialog() {
            // Clone dialog
            $('#pnlSectionsToClone').dialog(
              { autoOpen: false,
                modal: true,
                width: 'auto',
                height: 'auto',
                resizable: false
            });

            // Need add this line below, otherwise the buttons 
            // inside dialog will not postback
            $("#pnlSectionsToClone").parent().appendTo(jQuery("form:first"));
        }

3. In Firefox or IE8+, the dialog layout looks OK; but in IE7 (yes, many people are still using IE7), the dialog title looks like this:



This is because IE7 does not understand CSS style width:'auto'. To fix this issue, we need to manually assign width for the title when the dialog is created:

        function CreateCloneDialog() {
            // Clone dialog
            $('#pnlSectionsToClone').dialog({ autoOpen: false,
                modal: true,
                width: 'auto',
                height: 'auto',
                resizable: false,
                open: function (event, ui) {
                    // fix for width:auto in IE7. If width is specified, 
                    // the logic below is not needed.
                    var contentWidth = $(this).width();
                    $(this).parent().find('.ui-dialog-titlebar')
                    .each(function () {
                        $(this).width(contentWidth);
                    })
                },
                beforeClose: function (event, ui) {
                    //fix for width:auto in IE7
                    $(this).parent().css("width", "auto");
                } 
            });

Now the dialog looks OK in IE7:

SQL Except statement with Order By

The Except statement is easy to understand. For example, the result of "result set A Except result set B" is like below in grey:
But thing will easily go wrong in SQL statement when you use Except and Order By.

Take AdventureWorks database as an example here:

1. Run the 1st statement and notice BusinessEntityID=66 is in the result:

2. Run the 2nd statement and notice BusinessEntityID=66 is also in the result:


3. How about combining those two SQL statements together with Except? From the concept, the record BusinessEntityID=66 should not be in the result, right? Let's take a look:

It is still there! Why?!

The reason is: Order By actually belongs to the first Select statement, not the 2nd.

This is the result set for the 2nd statement without Order By:


The record BusinessEntityID=66 is NOT in the result. So the result of Except statement is actually correct.