This is a migrated thread and some comments may be shown as answers.

Why can't I declare the Client ID for RADControls in the HTML?

3 Answers 86 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Klaus
Top achievements
Rank 2
Klaus asked on 09 Oct 2009, 02:29 PM
I am trying to move my web apps into AJAX. I use server controls only for the initial page rendering of the DOM elements and then make web-service calls (using PageMethods or WCF) to populate or manipulate any grids, forms or data that exist in the page.

I recently purchased the AJAX RADControls since read that it is one of the best AJAX libraries available.

I added some of the Telerik controls to replace plain HTML tags (such as drop-down lists, inputs, etc.) but I am dissappointed in how difficult it is to find these controls in the DOM in order to manipulate them (especially when they are embedded within other ASP.Net server controls).

I am confused why I can't simply declare the Client IDs of my Telerik controls?
I am using my Telerik controls as 100% client-side controls so why am I not able to define my own Client IDs?


To find a Telerik Control I have to resort to such calls as:
var combo = $find("<%= RadComboBox1.ClientID %>");
var item = combo.findItemByText(text);
 (By the way, this code above will NOT run when you place your script code in a separate JS file which is a best practice that I prefer to follow.)

Does this limitation exist for a good reason?
Or is this limitation there because these are server controls that are being migrated to AJAX?
Is there a future version of the AJAX controls that will allow me to define my own Client IDs?

Please let me know if I misunderstood the architecture of these controls.

Thanks in advance for any explanation you may offer on this matter.

Klaus Barkhausen

3 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 09 Oct 2009, 02:59 PM
Hello Klaus,

Please refer to this blog post for useful tips on the matter.

Regards,
Paul
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Klaus
Top achievements
Rank 2
answered on 09 Oct 2009, 04:35 PM
This blog post explains what the ClientID, ID and UniqueID are - but it does not answer my question.

Why can't I declare the ID that will be used when rendering the server control in HTML?
Will I ever be able to define my own ClientIDs when using the Telerik Controls?

I use the Telerik RADControls for 100% client-side functionality so (as far as I am concerned) it seems ackwards that I am cannot assign them my own IDs so that I can more easily find them from my javascript code.

Please explain to me why this is not possible. 
I have worked with some other server controls by competitors that allow developers to declare the ID that will be assigned in the DOM to the server control when it is rendered. This makes it easier to work with the control and I can place all of my javascript in a separate JS file.

Thanks in advance for your help.

Klaus
0
Atanas Korchev
Telerik team
answered on 13 Oct 2009, 07:25 AM
Hi Klaus,

ASP.NET versions prior to 4.0 do now allow setting the ClientID property. As a result the ClientID is generated based on the ID property and and the INamingContainer (if any) of the control. RadControls for ASP.NET Ajax are based on ASP.NET Ajax which use the ClientID property as an unique identifier. That
is why you have to use  <%= RadComboBox1.ClientID%> with the $find() routine. Indeed this makes it very hard to use the control ID in external scripts without hardcoding the generated value.

Regards,
Albert,
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox
Asked by
Klaus
Top achievements
Rank 2
Answers by
Paul
Telerik team
Klaus
Top achievements
Rank 2
Atanas Korchev
Telerik team
Share this question
or