Question

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.

Was it helpful?

Solution

Try this:

<script type="text/javascript">var baseUrl = window.location.pathname;</script>

OTHER TIPS

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("~") %>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top