R – how to obtain the client id of a ContentPlaceHolder in an easy manner

asp.netclientidcontentplaceholdermaster-pages

i need to add JavaScript calls in some controls attributes, i am using master pages but in order to obtain the contentplaceholder client id i am iterating over the forms controls.
is there another way to obtain in the server side code of the content page?

 foreach (Control control in this.Form.Controls)
                {
                    if (control is ContentPlaceHolder)
                    {
                        contentPlaceHolderID = control.ClientID;
                        break;
                    }
                }

Best Answer

If there's only few controls like this you can set up a global variable:

var contentPlaceholderId = '<%= this.ContentPlaceholder1.ClientId %>'