The circle of life – ** .Net – Training – MOSS **

  • Past Post

  • Vistor Locations

  • Advertisements

Archive for the ‘AJAX’ Category

Update Panel and Default Button fix

Posted by Clayton James on July 7, 2008

Here is a workaround (hack) to fix the default button on a form that is enclosed inside an update panel.

Add the following to the .aspx page.
function ResetDefaultFired()
    __defaultFired = false;


Add the following property to each button that is enclosed inside the update panel


Blurb from msdn forum

The problem is in the used javascript to handle the default button in combination with Atlas.
When a default button is set in a Panel  the following attribute is rendered:
onkeypress = “Javascript:return WebForm_FireDefaultButton(event, ‘[buttonId]’);”

If you look at the code of WebForm_FireDefaultButton you will see a variable ‘__defaultFired’.This variable is used to just fire the event only 1 time in a roundtrip cycle. After you hit the enter key this variable is set to true. Because atlas is updating just a part of the screen this variable won’t be reset to false. So the second time you hit enter nothing happens or the default behavior of the browser is taking place (firing the first submit button on the screen in IE)
code snippet of the javascript WebForm_FireDefaultButton function
var __defaultFired = false;
function WebForm_FireDefaultButton(event, defaultButton) {
    if (!__defaultFired && event.keyCode == 13) {
        if (__nonMSDOMBrowser) {
            src = event.target;
        else {
            src = event.srcElement;
        tagName = src.tagName.toLowerCase();
        if ((tagName != “a”) && ((tagName != “input”) || ((src.type != “submit”) && (src.type != “reset”) && (src.type != “image”) && (src.type != “file”)))) {
            if (defaultButton.click != “undefined”) {
__defaultFired = true;
                if (__nonMSDOMBrowser) {
                    event.cancelBubble = true;
                return false;
    return true;


Posted in .NET 2.0, AJAX | 8 Comments »