Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You use <code>&lt;% ... %&gt;</code> to evaluate some JavaScript in an Underscore template but you use <code>&lt;%= ... %&gt;</code> if you want the output to end up in the result; from the <a href="http://underscorejs.org/#template" rel="nofollow">fine manual</a>:</p> <blockquote> <p>Template functions can both interpolate variables, using <code>&lt;%= … %&gt;</code>, as well as execute arbitrary JavaScript code, with <code>&lt;% … %&gt;</code>.</p> </blockquote> <p>You're looking to interpolate the <code>imgId</code> value into the result so you want this:</p> <pre><code>&lt;img src= "@Url.Content("+&lt;%= imgId %&gt;+")" alt="Assigned Details" /&gt; </code></pre> <p>Simplified Demo: <a href="http://jsfiddle.net/ambiguous/9gyKC/" rel="nofollow">http://jsfiddle.net/ambiguous/9gyKC/</a></p> <p>Presumably <code>@Url.Content</code> is something that gets run on the server to produce a <code>src</code> attribute for a given resource. If that's the case then you'll have to rethink how this works; the <code>&lt;%= ... %&gt;</code> stuff happens in the browser <em>after</em> <code>@Url.Content</code> has been executed so it will be too late when the Underscore template runs. Your note about an <code>imgId</code> error with this:</p> <pre><code>&lt;img src= "&lt;%= @Url.Content(string.Format("~/Content/Images/{0}", imgId)) %&gt;" /&gt; </code></pre> <p>supports this theory. Your server code doesn't know what <code>imgId</code> is, only the client-side JavaScript does.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload