Set img src at runtime
<p>Here is how I do it:</p>

<pre><code>var src = '&lt;%=Url.Content(Server.MapPath("~/AppData/images/myImages/1.jpg"))%&gt;';
$('#imgLocation').attr('src', src);
</code></pre>

<p>I have a solution with MVC project in it. The code above is in index.aspx, which is in:</p>

<pre><code>C:\Users\John\Documents\Visual Studio 2010\Projects\MyApp\MyApp\Views\index.aspx
</code></pre>

<p>Here is the image path:</p>

<pre><code>C:\Users\John\Documents\Visual Studio 2010\Projects\MyApp\MyApp\App_Data\myImages\locations\1.jpg
</code></pre>

<p>When I run my project, the image has src whose value is:</p>

<pre><code>src="C:UsersJohndocumentsisual studio 2010ProjectsMyAppMyAppAppDataimagesmyimages.jpg"
</code></pre>

<p>What is the problem?</p>
