Search code examples
jqueryasp.net-mvcspark-view-engine

Add script to Sparkview page


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.


Solution

  • Try this:

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