CODEDIGEST
Home Articles CodeDigest Tutorials FAQs
Skip Navigation LinksHome » FAQs » What is difference between UniqueID and ClientID in ASP.Net Controls ?   You are not logged in.
Search
 

Technologies
 

What is difference between UniqueID and ClientID in ASP.Net Controls ?
Submitted By Satheesh Babu B
On 7/5/2010 11:01:27 AM
Tags: Interview Questions,ASP.Net  

What is difference between UniqueID and ClientID in ASP.Net Controls ?


Control.ClientID 

ClientID will be a unique ID string that is rendered to the client to identify the control in the output HTML. It uses _ to include parent controls (container) ID to make it unique. For example, ct100_ContentPlaceHolder1_txtLogin. The client id for control will be generated by appending the parent container's(parent control) ID with the original control id with "_" as delimeter. In our example, ContentPlaceHolder1 is the ContentPlaceHolder ID of the master page which is the parent container for txtLogin.

 

To get the ClientID of a control,
txtLogin.ClientID

 

The client id can be used to identify the control in client side scripting like javascript.
 
Control.UniqueID
UniqueID is also a uniquely identifiable ID for a control but only used by ASP.Net page framework to identify the control. It uses $ to include parent controls (container) ID to make it unique. For example, ct100$ContentPlaceHolder1$txtLogin. Similar to ClientID, UniqueID is also generated by appending the parent container's(parent control) ID with the original control id but with $ delimeter.


To get the UniqueID of a control,
txtLogin.UniqueID

 
The unique id is used by the Asp.Net framework to identify the control when the page is posted back to the server.

 

 


 

Recent FAQs
  • View All FAQs..