Difference
between UniqueID and ClientID
-
S.No UniqueID ClientID 1 Meaning:UniqueID is also a uniquely identifiable ID for a control but only used by ASP.Net page framework to identify the control.i.e., UniqueID = HTML's name attributeMeaning:ClientID is a unique ID string that is rendered to the client to identify the control in the output HTML.i.e., ClientID = HTML's id attribute2 Delimiter used:It uses $ to include parent controls (container) ID to make it unique.For example, ct100$ContentPlaceHolder1$txtLoginDelimiter used:It uses _ to include parent controls (container) ID to make it unique.For example, ct100_ContentPlaceHolder1_txtLogin.3 UniqueID Generation:Similar to ClientID, UniqueID is also generated by appending the parent container's(parent control) ID with the original control id but with $ delimiterClientID Generation: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.4 How to get UniqueID of a control ?For example, use txtLogin.UniqueID for ct100$ContentPlaceHolder1$txtLoginHow to get CientID of a control ?For example, use txtLogin.ClientID for ct100_ContentPlaceHolder1_txtLogin.5 Where to use ?The unique id is used by the ASP.NET framework to identify the control when the page is posted back to the server.Where to use ?The client id can be used to identify the control in client side scripting like javascript.
Note:
ClientID
= HTML's id attribute and so when doing getElementById, we should
always give the ClientId.
Instead,
if we give UniqueID i.e., getElementById(Element's name), FireFox
will fail.
No comments:
Post a Comment