Difference between ID, ClientID and UniqueID?

H

Henri

Sorry to post so many questions but if you could tell me the difference
between these 3 IDs, it would help me a lot.
I don't know which one to use inside my custom control...
 
D

Darren Clark

ID is the id that you control is called.

ClientID is the ID that gets written to the html page. This works like such
ParentIControlID_myControlID
So if you have a ascx page.. caled myJobs and you have a label called myLabel
then the output to the page would be
<span id="myJobs_myLabel">


UniqueID (Not sure how to explain... so here is the MDSN stuff)
For example, if you include an ASP.NET Label Web server control in a Repeater server control, and assign the Label control an ID property value of MyLabel, and the Repeater an ID of MyRepeater. If you bind data to the Repeater to an ArrayList object with three entries, the resulting UniqueID properties for each instance of the Label server controls are MyRepeater:ctl0:MyLabel, MyRepeater:Ctl1:MyLabel, and MyRepeater:Ctl2:MyLabel.
 
H

Henri

Thanks for your explanation Darren :)
"Darren Clark" <[email protected]> a écrit dans le message de ID is the id that you control is called.

ClientID is the ID that gets written to the html page. This works like such
ParentIControlID_myControlID
So if you have a ascx page.. caled myJobs and you have a label called myLabel
then the output to the page would be
<span id="myJobs_myLabel">


UniqueID (Not sure how to explain... so here is the MDSN stuff)
For example, if you include an ASP.NET Label Web server control in a Repeater server control, and assign the Label control an ID property value of MyLabel, and the Repeater an ID of MyRepeater. If you bind data to the Repeater to an ArrayList object with three entries, the resulting UniqueID properties for each instance of the Label server controls are MyRepeater:ctl0:MyLabel, MyRepeater:Ctl1:MyLabel, and MyRepeater:Ctl2:MyLabel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top