Posts

Showing posts from October 26, 2010

ASP.NET 4.0 Feature - ClientIDMode Property

Let us see the new feature in ASP.NET 4.0 known as “ClientIDMode Property”. In the past we have seen that client id for any controls begin with “ctl00” and it always used to be a long names for eg: “gvBooks_ctl01_lnkOrderBook” . These id’s were very much needed when we used to while writing validations in javascript. Now in ASP.NET 4.0 we have the ClientIDMode Property which supports four different options as follows 1. AutoID – This is nothing but same as what we had prior to .NET 4.0 2. Predictable – This means that it concatenates the control name with the container (may be a contentplaceholder) for eg: contentplacholder1_btnSave 3. Static - This means that whatever the ID is set for the controls it uses that itself. 4. Inherit – This means that it will inherit the ClientIDMode property setting of the parent control. This is used in the different ways as seen below 1. It can be set in the web.config as <pages clientIDMode="Static"/> 2. It can be set at the control