title: Updating Image (runat server) Src using jQuery/ASP.NET
body: <p>I'm trying to update the source of an image using jQuery.  The problem is that the img is running server side as its initial source is being set on load.</p>
  
  <p>Here is the ASPX/HTML:</p>
  
  <pre><code>&lt;h2&gt;&lt;asp:Label ID="lblTitle" runat="server" /&gt;&lt;/h2&gt;
  &lt;img id="largeImg" runat="server" width="320" alt="Large Image" /&gt;
  &lt;p class="thumbs"&gt;
   &lt;a id="imgBACK" runat="server" title="Back"&gt;&lt;img id="imgBACK_Thumb" runat="server" /&gt;&lt;/a&gt;
   &lt;a id="imgFRONT" runat="server" title="Front"&gt;&lt;img id="imgFRONT_Thumb" runat="server" /&gt;&lt;/a&gt;
   &lt;a id="imgINSIDELEFT" runat="server" title="Inside Left"&gt;&lt;img id="imgINSIDELEFT_Thumb" runat="server" /&gt;&lt;/a&gt;
   &lt;a id="imgINSIDERIGHT" runat="server" title="Inside Right"&gt;&lt;img id="imgINSIDERIGHT_Thumb" runat="server" /&gt;&lt;/a&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>The sample jQuery code being used can be found <a href="http://www.webdesignerwall.com/demo/jquery/img-replacement.html" rel="nofollow noreferrer">here</a> or below:</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
  &lt;title&gt;Image Replacement&lt;/title&gt;
  &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $(document).ready(function(){
          $("h2").append('&lt;em&gt;&lt;/em&gt;')
      $(".thumbs a").click(function(){
  
          var largePath = $(this).attr("href");
          var largeAlt = $(this).attr("title");
  
          $("#largeImg").attr({ src: largePath, alt: largeAlt });
  
          $("h2 em").html(" (" + largeAlt + ")"); return false;
      });
  });
  &lt;/script&gt;
  &lt;style type="text/css"&gt;
  body {
      margin: 20px auto;
      padding: 0;
      width: 580px;
      font: 75%/120% Arial, Helvetica, sans-serif;
  }
  h2 {
      font: bold 190%/100% Arial, Helvetica, sans-serif;
      margin: 0 0 .2em;
  }
  h2 em {
      font: normal 80%/100% Arial, Helvetica, sans-serif;
      color: #999999;
  }
  #largeImg {
      border: solid 1px #ccc;
      width: 550px;
      height: 400px;
      padding: 5px;
  }
  .thumbs img {
      border: solid 1px #ccc;
      width: 100px;
      height: 100px;
      padding: 4px;
  }
  .thumbs img:hover {
      border-color: #FF9900;
  }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h2&gt;Illustrations&lt;/h2&gt;
  &lt;p&gt;&lt;img id="largeImg" src="images/img1-lg.jpg" alt="Large image" /&gt;&lt;/p&gt;
  &lt;p class="thumbs"&gt;
      &lt;a href="images/img2-lg.jpg" title="Image 2"&gt;&lt;img src="images/img2-thumb.jpg" /&gt;&lt;/a&gt;
      &lt;a href="images/img3-lg.jpg" title="Image 3"&gt;&lt;img src="images/img3-thumb.jpg" /&gt;&lt;/a&gt;
      &lt;a href="images/img4-lg.jpg" title="Image 4"&gt;&lt;img src="images/img4-thumb.jpg" /&gt;&lt;/a&gt;
      &lt;a href="images/img5-lg.jpg" title="Image 5"&gt;&lt;img src="images/img5-thumb.jpg" /&gt;&lt;/a&gt;
      &lt;a href="images/img6-lg.jpg" title="Image 6"&gt;&lt;img src="images/img6-thumb.jpg" /&gt;&lt;/a&gt;
  &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Currently, all image sources are perfect at load (the small and large images are being loaded via the codebehind).  However, clicking on the thumbnails does not change the large image because it's running server side.</p>
  
  <p>Any ideas on how to fix this?</p>
  
  <p>Thank you very much in advance!  After banging my head against the wall for far too many hours, I'm finally throwing in the towel (for at least a few hours).</p>
  
  <p>Thanks!</p>
  
  <p>-Adam</p>