Wednesday, May 16, 2007

I've got a TextBox and a Button, I want when I press Enter within the TextBox, it will trigger the Button, after that, the Cursor, will go back to the TextBox.

1.You can add a Javascript function in your page, as shown below:
_function _doSubmit()
{
if_(event.keyCode==13)
_document.all.xxx.click();
}
2. And then add this : _onkeydown="_doSubmit();" in the onkeydown event of the target TextBox.
3. After that, in your code-behind page, set the cursor back to the TextBox by using the postback method in your PageLoad event. e.g. this.TextBox1.Focus();

No comments: