U can use script to achieve that functionality
function click (e, buttonid){
var t = document.getElementById(buttonid);
if (typeof t == 'object')
{
if(navigator.appName.indexOf("Netscape")>(-1))
{
if (e.keyCode == 13)
{
t.click();
return false;
}
}
if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
{
if (event.keyCode == 13)
{
t.click();
return false;
}
}
}
}
//code behind
TextBox1.Attributes.Add("onkeypress", "return click(event,'" + Button1.ClientID + "')");
The code behind generates the following code:
<input name="TextBox1" type="text" id="TextBox1" onkeypress="return click(event,'Button1')" />
This causes web control Button1 to be clicked when the enter key is hit inside TextBox1.
This can easily be extended to support other browsers either by browser detection or object detection.
|