在 protected void Page_Load(object sender, EventArgs e) 中為Textbox加入Keydown事件
TextBox1.Attributes.Add("onkeydown", JScript事件)
Enter的KeyCode是13 以下為程式碼
1: if(event.which || event.keyCode)
2: {
3: if ((event.which == 13) || (event.keyCode == 13))
4: {
5: __doPostBack('Search1$LinkButton1','');
6: //參照render後的Html原始碼得知要參考的事件控制項觸發事件,加入到Textbox keydown事件中
7: return false;
8: }
9: }
10: else
11: {
12: return true
13: };
14:
15:
16:
17: utton1','');return false;}} else {return true}; ");
整行如下
1: TextBox1.Attributes.Add("onkeydown",
2: "if(event.which || event.keyCode){
3: if ((event.which == 13) || (event.keyCode == 13))
4: {__doPostBack('Search1$LinkButton1','');return false;}} else {return true};
5: ");
全站熱搜
留言列表