views:

21

answers:

2

Hi I've created a simple form with a link button. In my page load I set default button to that linkbutton as

this.Form.DefaultButton = this.btnSearch.UniqueID;

it is working fine in IE but not in Firefox.

Anyone has solution?

A: 

Take a Panel control within form and put all controls which are on form within panel. It should work.

UPDATE
Use JQuery And add this Plugin

Ismail
Hi thank you for your quick response. I tried like this but not working (I've a master page)
Nagu
I've updated my answer
Ismail
A: 

This seems to be an issue in FF and you can solve by using this code.

Keep it at the end of the page so that it overrides the WebForm_FireDefaultButton method rendered by ASP.NET.

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) {
        if(typeof(defaultButton.click) != "undefined")
            defaultButton.click();
        else
            eval(unescape(defaultButton.href.replace("javascript:", "")));

        event.cancelBubble = true;

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

}

Muhammad Akhtar