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

error CS1056: Unexpected character '$'

1 Answer 216 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 05 Sep 2012, 04:17 PM
Good day,
I'm using the standard code example for the ListBox and I'd like to have sorting.  My Master page generates a unique name and adds it to all of the form element names, so  the code looks like this:
<telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">         
<script type="text/javascript">             
//<![CDATA[
            
var listBox;             
function pageLoad() {                 
listBox = $find("<%= ctl00$MainContent$SortUC$RadListBox1.ClientID %>");           
}

etc...etc

However when I run the code, I'm getting this error:
error CS1056: Unexpected character '$'

and its pointing to the line with the form name. I can find scant little info on the internet about this, so can somone
please tell me how this is supposed to work if it can't handle any non-alphanumerical chars in the string?

Thanks,
Alan R


1 Answer, 1 is accepted

Sort by
0
Ivan Zhekov
Telerik team
answered on 06 Sep 2012, 08:22 AM
Hello, Alan.

You need to provide the server ID of the control, not the generated one. In this case it seems that the ID is RadListBox1 so the end this snippet should be:

function pageLoad() {
    listBox = $find("<%= RadListBox1.ClientID %>");
}

Regards,
Ivan Zhekov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ListBox
Asked by
Alan
Top achievements
Rank 1
Answers by
Ivan Zhekov
Telerik team
Share this question
or