<HTML>
<Head>
<Title> Guanzhong youxia -- method for obtaining the focus of textbox in. Net </title>
</Head>
<Body>
<Form ID = "form1" method = "Post" runat = "server">
Method for obtaining the focus of textbox in. Net <br/>
<Asp: textbox id = "txtwords" runat = "server" width = "100%" textmode = "multiline"> </ASP: textbox>
<Br/>
For more information, visit Guanzhong Ranger's blog: <a href = "http://hi.baidu.com/activezfj" Title = "click to visit" target = "_ blank"> http://hi.baidu.com/activezfj </a>
<Br/>
<! --
Add the script here
-->
</Form>
</Body>
</Html>
Method 1:
Replace "add script here" with: document.form1.txt words. Focus ();
Method 2:
Replace "add script here" with: Document. getelementbyid ('<% = txtwords. clientid %>'). Focus ();
Method 3:
Cedit * P = (cedit *) getdlgitem (the ID of the edit box );
P. setfocus ();
Method 4:
Define a variable of the cedit type for this edit box, such as m_edit;
Use m_edit.setfocus () as needed.
You can do it.
Function text_focus () {window. form1.textbox1. Focus ();} use this function in the onload_keydown event on the ASPX page
Button1.attributes. Add ("onclick", "javascript: Document. All. kongjianid. Focus ();")