<html>
    <head>
<title>关中游侠——.Net中TextBox获得焦点的方法</title>
    </head>
    <body>
        <form >http://hi.baidu.com/activezfj</a>
            <br />
            <!--
                在这里加入脚本
            -->
       </form>
    </body>
</html>

方法一:
        将“在这里加入脚本”替换为:document.Form1.txtWords.focus();

方法二:
        将“在这里加入脚本”替换为:document.getElementById('<%=txtWords.ClientID%>').focus();

方法三:  
  CEdit   *p=(CEdit*)GetDlgItem(编辑框的ID);  
  p.SetFocus();  
方法四:  
  给这个编辑框定义一个CEdit类型的变量,比如m_edit;  
  在需要的地方,用m_edit.SetFocus()就可以了。  
  就可以搞定了

function text_focus() { window.form1.textbox1.focus(); } 在aspx页面中onload_keydown事件中使用该函数

Button1.Attributes.Add("onclick",   "javascript:document.all.kongjianId.focus();")

 

 

相关文章:

  • 2022-12-23
  • 2021-08-21
  • 2022-02-21
  • 2021-07-15
  • 2021-10-16
  • 2022-03-06
  • 2022-12-23
  • 2021-12-19
猜你喜欢
  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
  • 2022-12-23
  • 2021-06-24
  • 2021-05-21
  • 2022-12-23
相关资源
相似解决方案