Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Got error: Identifier expected on
JavaScript
var myURL = '<%=ConfigurationManager.AppSettings["myURL"].ToString() %>';
....
// In my Web.Config
  <appSettings>
    <add key="myURL" value="http://..." />
  </appSettings>

I could not figure out where the bug is. Appreciate if you can point out.
Posted
Comments
Rashmi Sutar 8-Jul-15 8:37am    
Hi, you want to do it using JS only?

1 solution

Add this on the top of your page,

<%@ Import Namespace="System.Configuration" %>


or use fully qualified namespace to use ConfigurationManager :-)
 
Share this answer
 
v2
Comments
Suvendu Shekhar Giri 8-Jul-15 8:48am    
5*. Perfect !
Akhil Mittal 9-Jul-15 1:09am    
Thanks
s yu 8-Jul-15 9:50am    
Added the line either before or after <html> tag, but the error still exists. I have another aspx file, which contains the same code and works well w/o adding the 'Import' line. The problem reported here is in a .html file. Then, I created a new .aspx file w/ the code in the previous .html file, the problem was gone. Thanks.
Akhil Mittal 9-Jul-15 1:08am    
If you wish you can accept this given solution as an accepted answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900