error CS1056: Unexpected character '$'

2 posts, 0 answers
  1. Alan
    Alan avatar
    1 posts
    Member since:
    Jun 2011

    Posted 05 Sep 2012 Link to this post

    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


  2. Ivan Zhekov
    Admin
    Ivan Zhekov avatar
    540 posts

    Posted 06 Sep 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top