I’m trying to make my app more flexible. I’m using a third party component (rich text editor). On the page the component is used, I need to register some javascript. At the moment, this is done so :
<script type="text/javascript" src="../../Resources/Xinha/my_config.js"></script>
I tried some options, like this one but none worked.
<script type="text/javascript" src="<%=ConfigurationSettings.AppSettings["Xinha.PathToPackage"]%>/XinhaCore.js"></script>
Are there any suggestions on what I am missing or isn’t this possible?
Thanks in advance.
What you’re doing is definitely possible but it can really create some havoc w/ ASP.NET’s ajax implementation – ASP.NET Ajax doesn’t like “<%=%>” in the header…
You can try either of these approaches from the code behind for something a little safer:
OR
UPDATE:
Per the recommendation that you not use relative pathing, I fully agree. If you want to have a path that works throughout your site but is referenced from the web.config, make it a virtual path:
Then in your code:
Then use scriptPath in the
Page.ClientScript.RegisterClientScriptIncludeorScriptManager.RegisterClientScriptIncludecall.