Hints And Tips research knowledge archive
Tip# 500
Sponsored Links
 
Subject: ASP.NET: DefaultButton + Firefox + textarea bug - Fix
Updated: Oct-22-2007
Rating: Not Rated
By: Rocky Moore - Member #: 461
Location: Klamath Falls, Oregon USA
Website: www.ReflectedThought.com
Category: Computers > Programming > .NET > ASP.NET
Rate This Tip (10=Great):  1  2  3  4  5  6  7  8  9  10
Got you defaultButton working on your form and then find out it is not working on with Firefox.  Issue that any multiple line textboxes (textarea) is not receiving linefeeds.  You hit ENTER but it does not give you a new line inside the textbox.

Seems there is a problem with WebForm_FireDefaultButton javascript function where it is not Firefox compatible.  I found a fix at:

http://developmentnow.com/g/8_2006_8_0_0_812838/Form-DefaultButton-behaves-incorrectly.htm

That describes how to patch that routine by changing the first two lines to make it compatible.  I made the changes, placed the funtion in a js file and then added to the bottom of my master page and it all works fine from what I can see.

Here is what I have in my js file I call DfBntFix.js:


var __defaultFired = false;

function WebForm_FireDefaultButton(event, target) {

    var element = event.target || event.srcElement;
    
    if (!__defaultFired && event.keyCode == 13 && !(element && (element.tagName.toLowerCase() == "textarea"))) {


        var defaultButton;

        if (__nonMSDOMBrowser) {

            defaultButton = document.getElementById(target);

        }

        else {

            defaultButton = document.all[target];

        }

        if (defaultButton && typeof(defaultButton.click) != "undefined") {

            defaultButton.click();

            event.cancelBubble = true;

            if (event.stopPropagation) event.stopPropagation();
            
            return false;

        }

    }

    return true;

}



This issue is suppose to be fix in future versions.

[Submit DIGG for this tip]


-----------
Note: Use the tips posted on this site at your own risk. The tips are posted by the public and as such may or may not be valid.

Sponsored Links
     
Categories
hints and tips gold divider
Sponsor Sites To Visit
www.SaintsInLight.com
Thoughts on the Christian walk
along various Christian links.

CICK HERE
www.BringingInTheHarvest.com
Christian:  The harvest is ripe and
the day is short, we need to bring in
the harvest while there is time!

CLICK HERE
XML RSS News Feed For Recently Posted Hints And Tips  RSS Feed
You can now get updates to the Recent Tips section by using RSS. The address is:

HintsAndTips.com/Rss.aspx

* Posting Tips *
To post a Tip, Recommendation or Tips Wanted, simply browse to the category you feel is a best fit for your post (click on the Recommention or Tips Wanted tab if fitting) and then click on "New Post" option.
(C) Copyright 1998-2010 All Rights Reserved