Wednesday, March 28, 2012

web control ID, unique Id

Hello,

Please can someone explain the difference between web control's ID , uniqueID and clientID properties .

How these three are different and how and when to use them.

help please...

I didn't know the answer, but I've been using the ClientID recently when creating dynamic controls, so I thought I'd see what the VS documentation says.

ID -The programmatic identifier assigned to the control.

Setting this property on a server control provides you with programmatic access to the server control's properties, events, and methods. This property can be set by Web developers by declaring an ID attribute in the opening tag of an ASP.NET server control.

UniqueID

This property differs from the ID property in that the UniqueID property includes the identifier for the server control's naming container. This identifier is generated automatically when a page request is processed.

ClientID -The server control identifier generated by ASP.NET.

Sometimes, it is not possible to assign a unique name to a control. For example, if a Repeater control contains a Label control in one of its templates, an instance of that Label control is rendered for each item in the Repeater control. To prevent naming conflicts when multiple instances of a control are rendered, ASP.NET automatically generates a unique ClientID value for each server control on a page. The ClientID value is generated by concatenating the ID value of the control and the UniqueID value of its parent control. If the ID value of the control is not specified, an automatically generated value is used. Each part of the generated ID is separated by an underscore character (_).

0 comments:

Post a Comment