Page_Load:
if(!IsPostBack)
{
Button1.Attributes["onkeydown"]="if (event.keyCode==13) event.keyCode=9";
Button2.Attributes["onkeydown"]="if (event.keyCode==13) xxxxx";//需要具体看你想执行什么函数,客户端还是服务端
}

解决方案 »

  1.   

    复制下面的代码到你的 html 文件的 <head> 和 </head> 之间:<script language="JavaScript1.2">var travel=true
    var hotkey=104
    var destination="index.htm"
    if (document.layers)
    document.captureEvents(Event.KEYPRESS)
    function backhome(e){
    if (document.layers){
    if (e.which==hotkey&&travel)
    window.location=destination
    }
    else if (document.all){
    if (event.keyCode==hotkey)
    window.location=destination
    }
    }
    document.onkeypress=backhome</script>
     
    使用说明:
     其中hotkey=104的值就是热键字母的键值,你可以修改为你需要的热键
    destination="index.htm"就是按了“热键”后链接的文件名。 
    你可以改一下:判断是热键ENTER后执行 focus就OK!
      

  2.   

    acewang(平平安安过一年)你那个不妥吧,对操作人员来说他们是不愿意接受的
      

  3.   

    就是acewang(平平安安过一年)的方法
    为什么不会接受!
      

  4.   

    Button1.Attributes["onkeydown"]="if (event.keyCode==13) someXXX()";//客户端
    Button1.Attributes["onkeydown"]="if (event.keyCode==13) __doPostBack('HiddenBtn',''); return false;";//HiddenBtn是个隐藏的LinkBtton
      

  5.   

    YAOTIEBING(我爱我家) 仿佛用不成功
    还有Button1.Attributes["onkeydown"]="if (event.keyCode==13) event.keyCode=9";
    后你就会找不到标了.
      

  6.   

    acewang(平平安安过一年)我正在测试
      

  7.   

    to acewang(平平安安过一年)
    Button1.Attributes["onkeydown"]这是什么事件?什么情况下触发.我照你的做了怎么没有反应
      

  8.   

    sorry:
    写的急,应该是TextBox1 /TextBox2
      

  9.   

    Text1,2是HTML上的控件,转为服务端运行客户端
    Page_Load:
    if(!IsPostBack)
    {
    Text1.Attributes["onkeydown"]="if (event.keyCode==13) event.keyCode=9";
    Text2.Attributes["onkeydown"]="if (event.keyCode==13) alert('ok')";
    }
      

  10.   


    private void Page_Load(object sender, System.EventArgs e)
    {
      if(!IsPostBack)
      {
       TextBox1.Attributes["onkeydown"]="if (event.keyCode==13) event.keyCode=9";
       TextBox2.Attributes["onkeydown"]="if (event.keyCode==13) ss()";
       }
    }
    private void ss()
    {
      TextBox1.Text ="djalkfjsd";
    }这个段代码的ss()函数应该怎么调用
      

  11.   

    to acewang(平平安安过一年)
    to ZXYSOSO(【我很想飛】) 
    看看我上面的例子
      

  12.   

    页面上放置一个LinkButton,visible=false,将你的ss里面的动作放LinkButton事件里,
    "if (event.keyCode==13) __doPostBack('LinkButton1',''); return false;";
      

  13.   

    "if (event.keyCode==13) {__doPostBack('LinkButton1',''); return false;}";