Clientid usage in Asp.net

Source: Internet
Author: User

When using clientid, you may encounter the following problems:

Obtain the Server Control identifier generated by ASP. NET.

Problem 1: The Control ID of Asp.net must be used in the page JavaScript of the user control.
Problem 2: The Asp.net Control ID must be used in the subpage JavaScript of the master page.
Solution:
Document. getelementbyid ("<% = textbox1.clientid %>"). value = "1234567 ";

ThisCodeYou can access the server-side controls on the client. Because ASP. NET generates different names for displaying the server-side controls on the client, this function is useful.

Note: The Asp.net controls are static controls (controls added by tools)

Question 3: How to obtain the clientid of the dynamically created control exists: you cannot use "<% = textbox1.clientid %>" on the page ". method (the method is not available because the control is dynamically created), and textbox1.clientid cannot be used in the page script (the obtained ID is incorrect ).

Related Article

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.