title: Moving Url.Action into Jquery/JS? (MVC Web App)
body: <p>Environment: ASP.NET 3.5, MVC 2 Web App, in the View file Index.aspx</p>
  
  <p>I have the following jqGrid (excerpt of code):</p>
  
  <pre><code>    $("#list").jqGrid({
          url: '&lt;%= Url.Action("GridData") %&gt;',
          datatype: 'json',
  </code></pre>
  
  <p>This is in an inline JS function called populateGrid. I need to move this function out of the View and into its own JS. In order to do this I need to store the &lt;%= Url.Action("GridData") %> as a variable in javascript.</p>
  
  <p>This:</p>
  
  <pre><code>var griddata = &lt;%= Url.Action("GridData") %&gt;;
  </code></pre>
  
  <p>doesn't appear to work. I am wondering what syntax I should use and/or how I can do this. The populateGrid function is going to be called by multiple pages so that is why it is being put into a .js file.</p>