views:

1852

answers:

2

Trying to include ThickBox (from http://jquery.com/demo/thickbox/) in an ASP.NET application.

Visual Studio is failing when I try to run the application with the error: js\ThickBox\jquery-1.2.6.min.js(11): error CS1056: Unexpected character '$'

Using Visual Studio 2008 and jquery 1.2.6

+3  A: 

Maybe is because of the conflict between jQuery $ and the one defined by the asp.net script library.

You can call jQuery.noConflict() then use jQuery instead of $. For example instead of $("#test") you will call jQuery("#test").

See http://docs.jquery.com/Core/jQuery.noConflict for more info.

Aleris
Never knew about that. Thanks for the answer, I fixed it by removing the runat="server" attribute of the link. Was hoping to use that to resolve the path from the master page...
Bryce Fischer
+6  A: 

CS1056 is obviously a C# compiler error. This kind of thing happens when you put runat="server" in a client script include tag (Visual Studio attempts to compile your .js file as if it was C#). Just remove the runat="server" attribute and try again.

rciq
I had some other compiler error, which was actually coming from the js file itself. Your advice helped me :)
Dragoljub
+1 Great answer, i was fighting with this error for last 3 hours. But never expected that this can be a reason
Shantanu Gupta