Thursday, May 8, 2008

Function for Transfering Focus to Submit Button When the Enter is press after entereing data in textBox

On C#
txtDescription.Attributes.Add("onkeypress", "return clickButton_focus(event,'" + btnSave.ClientID + "');");

On html

function clickButton_focus(e, buttonid)
{
var bt = document . getElementById(buttonid);
if (typeof bt == 'object'){
if(navigator .appName . indexOf("Netscape")>(-1)){
if (e . keyCode == 13){
bt.click();
return false;
}
}
if (navigator .appName.indexOf("Microsoft Internet Explorer")>(-1)){
if (event .keyCode == 13){
bt .click();
return false;
}
}
}
}

No comments: