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

Getting The ClientID of Telerik Controls

2 Answers 402 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Adipa Gunasekara
Top achievements
Rank 1
Adipa Gunasekara asked on 10 Mar 2010, 01:55 PM
Hi,

I am trying to get a control ID of a telerik RadTextBox, using following syntax

var pwd1 = document.getElementById("<%= passwordTextBox.ClientID %>");
and I also tried
var pwd1 = $find("<%= passwordTextBox.ClientID %>");

The script is used inside a user control,

This gives following error,

The Controls collection cannot be modified because the control contains code blocks




And when I use,
var pwd1 = $find("<%# passwordTextBox.ClientID %>");

when look at the source, it is just empty string in place (var pwd1 = $find("");)

I tried both ClientID and UniqueID , but it does not works either,

(This code is used inside a UserControl and page uses themes hence it's not possible to remove runat="server" tag in the header section)



2 Answers, 1 is accepted

Sort by
0
Accepted
Carl
Top achievements
Rank 1
answered on 10 Mar 2010, 02:46 PM
The reason why you are receiving that error is because you have the "<% %>" tags in the <head> section of your page. If you wrap these in RadScriptBlocks the $find(....) statement should be all you need.
0
Adipa Gunasekara
Top achievements
Rank 1
answered on 11 Mar 2010, 04:52 AM
Thanks Carl. It works fine now :).
Tags
General Discussions
Asked by
Adipa Gunasekara
Top achievements
Rank 1
Answers by
Carl
Top achievements
Rank 1
Adipa Gunasekara
Top achievements
Rank 1
Share this question
or