protected void MySetFocus() 
{
        txtKeyWord.Attributes.Add("onkeydown",
            "if(event.keyCode==13){" +
                "document.all.ctl00_SearchBarOnButtom1_btnSearch.focus();" +
                "document.all.ctl00_SearchBarOnButtom1_btnSearch.click();" +
            "}");
 }
我在别人的程序里看到这样一段代码,高手能不能帮我每句解释一下呀,还有整个方法
是干嘛用的呀。小生不甚感激!

解决方案 »

  1.   

    txtKeyWord.Attributes.Add("onkeydown"
    添加键盘事件,如果是回车键则执行下面的语句
    "document.all.ctl00_SearchBarOnButtom1_btnSearch.focus();" 
    "document.all.ctl00_SearchBarOnButtom1_btnSearch.click();" 
      

  2.   

    如果在keyword文本框中按回车,将焦点置于btnSearch,然后进行检索操作(btnSearch.click())以上是在服务端将脚本注册到客户端。
      

  3.   

    谢谢上面各位高手的指导,小生还有一个问题:ctl00_SearchBarOnButtom1_btnSearch是啥东东呀,我知道SearchBarOnButtom1是一个用户控件,btnSearch是按钮ID,那前面的ct100是什么就不清楚了,还有有哪高手教教我怎么给分罗。
      

  4.   

    ctl00_SearchBarOnButtom1_btnSearch是你的btnSearch的clientID,要运行了后才会产生的