案例如下:
一般情况下
当一个页面有TextBox以及Button的时候
当光标停留在TextBox上 此时按Enter键 回车
就会发现光标将焦点停留在Button上
并且触发了Button的按钮事件
本例实现如下效果
0.一个包含[姓名TextBox1]和[备注TextBox2]以及[确定Button按钮]的页面
1.屏蔽按钮对回车键的响应 而只响应鼠标的点击
2.以及实现Enter键->Tab键的转换
即TextBox1非空时 按回车键 光标转到TextBox2
当TextBox2非空时 按回车键 光标转到Button
当光标停留在Button上时 按回车键 光标转到TextBox1
---------------------------------------
相关代码示例如下:

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

后台代码:
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.TextBox1.Attributes.Add("onkeydown", "TextBox1onKeyDown();");
this.TextBox2.Attributes.Add("onkeydown", "TextBox2onKeyDown();");
this.Button1.Attributes.Add("onkeydown", "Button1onKeyDown();");
this.Button1.Attributes.Add("onclick", "btnOnClick();");
this.TextBox1.Focus();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("onclickServer");
}
}