Add script to Sparkview page
-
15-11-2019 - |
Pergunta
I have an application based on Sparkview. I need to feed the current url to some jquery, I could do with doing something along the lines of http://forums.asp.net/t/1550405.aspx
I tried to modify the application.spark and add
<script type="text/javascript">var baseUrl = '<%= ResolveUrl("~/") %>'</script>
Unfortunately I get an exception The name 'ResolveUrl' does not exist in the current context. I dont know much about sparkview, so if anyone could help it would be much appriciated.
Solução
Try this:
<script type="text/javascript">var baseUrl = window.location.pathname;</script>
Outras dicas
just as an FYI, Spark will resolve any ~/
paths it finds without an explicit call to ResolveUrl. for example:
<script type="text/javascript" href="~/Scripts/MyScript.js"></script>
Try this:
<%= Url.Content("~") %>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow