Id, the difference between clientid and uniqueid, clientiduniqueid

Source: Internet
Author: User

Id, the difference between clientid and uniqueid, clientiduniqueid

I,
ID is the ID specified during design.
ClientID is used when the control is generated on the client page and accessed by the client.
UniqueID is used when you need to participate in server return.
Note:When a control is a subcontrol (for example, a Button in a user control), ClientID is used as the control's ID attribute on the HTML page, and UniqueID is used as the control's Name attribute, if it is not a child control, the ClientID and UniqueID are the same.
For example:
MyControl1 is a user control that contains a button with the ID of Button1 and runs MyControl1 on a page. The following is the HTML code of the page.
<input type="submit" name="MyControl1:Button1" value="Button" id="MyControl1_Button1" />ClientID:MyControl1_Button1 UniqueID:MyControl1:Button1
Supplement:To write client Event code for a control in a user control, you must obtain the ClientID of the control if you want to write it in the control.
Ii. ASP. NET Server-side controls have three ID-related property IDs: ClientID and UniqueID..
ID
Indicates the identifier of the control's server-side programming. This ID is required for writing the server-side code, this ID allows you to program access to the properties, methods, and time of the server-side controls on the server.
ClientID
The ID of the client control generated by the server. It is often used to access the HTML elements displayed by the server control in the client script.
Generally, it is the same as the server ID. Sometimes, it cannot generate a unique name for the control. For example:
If the Repeater space contains a Label control in a template, multiple HTML elements of the Label are generated on the client,
ASP. NET generates a unique ClientID for each server control. ClientID is generated by connecting the UniqueID value of the parent control of the Child control with the ID value of the control.
UniqueID
Obtains the unique, hierarchical identifier of a server control.
When you place controls in repeated controls (Repeater, DataList, and DataGrid), multiple server-side controls may be generated, which requires distinguishing the various controls on the server, so that their ID attributes do not conflict.
UniqueID is generated by connecting the UniqueID value of the parent control of the Child control with the ID value of the control. Each part is connected by the character specified by the IdSeparator attribute.
By default, the IdSeparator attribute is a colon character (:). This attribute is newly added in. Net Framework2.0.

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.