ID vs UniqueID vs ClientID vs UniqueClientID vs StaticClientID? ID vs UniqueID vs ClientID vs UniqueClientID vs StaticClientID? asp.net asp.net

ID vs UniqueID vs ClientID vs UniqueClientID vs StaticClientID?


  • The ID is the serverside ID that you use in your code.
  • The UniqueId corresponds to the "name" attribute of the generated HTML element.
  • The ClientID corresponds to the "id" attribute of the generated html element. So it depends which attribute you need (name is sent with form post, id is used for DOM manipulation).
  • Not sure what the uniqueclientid is :)

ASP.Net 4 adds clientIdMode which allows you to force the id attribute to match the serverside id (and thus be more predictable) if you set it to "static".


Use the ClientID property.

ClientIDMode is there to support the ability to 100% set the actual ID used by the control..or not. Your choice. Basically it aids in writing javascript code.


The ClientIDMode was added to ASP.NET 4 to allow control if you want it. It is particularly useful for client side libraries such as jQuery. ASP.NET's magic hinges on the uniqueness of controls. If you decided to use Static make sure they are unique, as you may face some unexpected runtime errors down the road.