This may not be the best solutions, but it was the only one I could find after spending hours searching for an answer. Searching MSDN for CaptureEvent, I found an article on making a hot key for a page. With some modification, this seems to work well in making a default button.
In my code behind file I call this routine to send out Javascript that will intercept the ENTER key (13) and call a postback for the proper control. Could also have it locate and call the onclick if you like.
To use, simply call the method passing the Web control you wish to use as the default button.
Note: This may cause a text area control that accepts ENTER to not function properly. For me this was not an issue and I have not tested to see the results.
private void SendScript(Control SubmitButton)
{
string buttonID = SubmitButton.UniqueID.Replace(":","$");
string script=@"
<script language='JavaScript' >
<!--
if (document.layers)
document.captureEvents(Event.KEYPRESS);
function checkKey(e)
{
if (document.layers)
{
if (e.which==13)
{
__doPostBack('"+buttonID+@"','');
}
}
else if (document.all)
{
if (event.keyCode==13)
{
__doPostBack('"+buttonID+@"','');
}
}
}
document.onkeypress=checkKey;
//-->
</script>";
Page.RegisterClientScriptBlock("EnterTrap",script);
}