Accessing ID from client-side

(A) BehaviorID
The BehaviorID property (common to all extenders in the Toolkit) is used to get a reference to the client side object (called behavior because it’s a class
that inherits from the Sys.UI.Behavior class).A behavior is a component that extends the functionality of the DOM element that it is associated with. Realize a component is different from a DOM element.
The $find function returns an ASP.NET AJAX client side Component by it’s ID & NOT the DOM element
Similarly $get returns the DOM element.
The Behavior class should not be instantiated directly; it is a base class for other behaviors to derive from.
Based on the ASP.NET life-cycle, the page side client functions would be fired after the page is loaded. Hence we can assign the behaviorId value in the
server side page_Load event.  Few examples of BehaviorID

<ajaxToolkit:ModalPopupExtender BehaviorID ="mpebehavior" ID="ModalPopupExtender1" runat="server"></ajaxToolkit:ModalPopupExtender> 
<script language ="javascript">
    function pageLoad() {
        var mpeBehaviorhandle = $find("mpebehavior");
    function NowShown() {

var obj = $find("watermarkextender_behaviorID_here");
var Text = obj.get_Text();

(B) ClientID=Predictable.
Use this value when the control is inside a data-bound control that has a ClientIDRowSuffix property (for example, ListView or GridView) and you want to be
able to access specific instances of the control in client script by using a key value from the database.
This option is for use in data-binding scenarios. If the control is a data-bound control that has a ClientIDRowSuffix property, the ClientID value for each
instance of the control is modified by appending the value of a field that you specify in the ClientIDRowSuffix property. For the GridView control, you can enter multiple field names separated by commas. If the data-bound control generates multiple rows but does not have a ClientIDRowSuffix property, or if you leave the ClientIDRowSuffix property blank, ASP.NET will use a sequential number as the ClientID suffix.

If you have set the ClientIDMode property to Predictable, set the ClientIDRowSuffix property to the name of the data field that you want to use to uniquely identify each instance of the control. For the GridView control, you can enter multiple field names separated by commas.
If you do not set the ClientIDRowSuffix property, ASP.NET uses a sequential number as the ClientID suffix. This is similar to the algorithm used for AutoID,
except that the number is placed at the end of the generated ID instead of before the control’s ID. In addition, the sequential number appears without a ctrl prefix  I myself have used this setting to refresh GridView rows through AJAX-WebService. Here’s a nice example —

If you want to use the AutoID setting you typically do not need to explicitly set the ClientIDMode property. The default value for a Web page is AutoID and the default value for a control in a page is Inherit. Therefore, if you do not set explicitly set the ClientIDMode property of the parent control or the page, a control will automatically inherit the AutoID setting.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s