在asp.net中需要解决的问题:如何实现回车代替Tab的功能。初学者,希望给明确的指点,也可以给更多的asp.net、C#相关的知识。万分感谢!
http://www.jb51.net/article/22351.htm
判断如果是enter键 就到下一格去
if (e.KeyData == Keys.Enter)
{
this.Focus();
GotoNextPosition();
}
判断keycode是回车阻止默认的提交事件,移动到下一个控件
<form id="f">
<input type="text" /><br />
<input type="text" /><br />
<input type="text" /><br />
<input type="text" /><br /><input type="submit" />
</form>
<script>
var input = document.getElementById('f').getElementsByTagName('input'),arr=[];
for (var i = 0; i < input.length; i++) {
if (input[i].type == 'text') {
arr.push(input[i]);
input[i].setAttribute('tab',arr.length);
input[i].onkeydown = function (e) {
e = e || window.event;
if (e.keyCode == 13) {
var index = parseInt(this.getAttribute('tab'), 10);
arr[index].focus();
return index >= arr.length;
}
}
}
}
</script>
if (e.KeyCode == Keys.Enter)
{
SendKeys.Send("{TAB}");
}