How to get the focus of textbox in. net

Source: Internet
Author: User

<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 ();")

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.