.Net中TextBox获得焦点的方法
2011-07-03 23:53
183 查看
<html> <head> <title>关中游侠——.Net中TextBox获得焦点的方法</title> </head> <body> <form id="Form1" method="post" runat="server"> .Net中TextBox获得焦点的方法<br /> <asp:textbox id="txtWords" runat="server" Width="100%" TextMode="MultiLine"></asp:textbox> <br /> 更多内容欢迎访问关中游侠的博客:<a href="http://www.0duinfo.com" title="点击访问" target="_blank">http://www.0duinfo.com</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()就可以了。
就可以搞定了
在aspx页面中onload_keydown事件中使用该函数
function text_focus() { window.form1.textbox1.focus(); }
Button1.Attributes.Add("onclick", "javascript:document.all.kongjianId.focus();")
相关文章推荐
- .Net中TextBox获得焦点的方法
- WPF 在TextBox失去焦点时检测数据,出错重新获得焦点解决办法
- .NET中TextBox控件设置ReadOnly=true后台取不到值三种解决方法
- 给TextBox添加失去焦点事件(两种方法)
- 设置下一个获得焦点的组件方法
- JQuery 中,使文本框获得焦点的方法
- JQuery下focus()无法自动获取焦点的处理方法 jquery如何使文本框获得焦点
- .net网站应用程序中,获得当前的用户名方法
- jq获得焦点focus,失去焦点blur,change()函数,js的onfocus,onblur,onchange()方法
- TextBox 绑定表的数字类型字段,清除文本框内容时,焦点不能移出文本框的解决方法
- easyui textbox 获得焦点,失去焦点处理
- webapp之登录页面当input获得焦点时,顶部版权文本被顶上去 的解决方法
- Bootstrap弹出框modal上层的输入框不能获得焦点问题的解决方法
- 禁止进入activity后EditText自动获得焦点的方法
- jQuery中给文本框获得焦点和失去焦点的方法
- 在js(jquery)中获得文本框焦点和失去焦点的方法
- JQuery下focus()无法自动获取焦点的处理方法 jquery如何使文本框获得焦点
- onfocus 获得焦点方法只获取一次input的值
- 调用focus方法使输入框获得焦点,不弹出软键盘的解决方法
- .NET中获得hInstance的几个方法