Add Dynamic Variable in URL Content in JQuery
<p>I am trying to add attach my variable on my script section, since my filename is in GUID format. The filename is in hidden field:</p>

<pre><code> string strDirectory = Server.MapPath(Url.Content("~/Content/AnnouncementImages/"));
 string[] strFiles = Directory.GetFiles(strDirectory);
 string strFileName = string.Empty;
      foreach (var strFile in strFiles)
       {
          strFileName = Path.GetFileName(strFile);
       }
 &lt;img id="myImg" src="@Url.Content("~/Content/AnnouncementImages/" + strFileName)" width="300" height="200" /&gt;    
 &lt;input type="hidden" id="hiddenStringFileName" value="@strFileName"/&gt;
</code></pre>

<p>In script section, I am trying to get this hidden field value:</p>

<pre><code>function fncAnnouncementLoad() 
{
   var filename = document.getElementById('hiddenStringFileName');

   //This is not working so far since it says cannot resolve symbol filename on below code:
   modalImg.src = '@Url.Content("~/Content/AnnouncementImages/" + filename);
}
</code></pre>