title: Apply CSS Class to Image in asp:Hyperlink?
body: <p>I'm using asp:Hyperlink to render linked images dynamically based on parameters in the URL. I need to be able to add a CSS class to the rendered img, and can't figure out how to do that.</p>
  
  <p>I know I can add "CssClass="blah"" to the asp:Hyperlink, but in the rendered HTML, only the a receives the css class. Like this:</p>
  
  <pre><code>&lt;a href="assets/images/blah.jpg" class="blah" id="ctl00_LeftContent_alternateImage4"&gt;
  &lt;img style="border-width: 0px;" src="assets/images/blahThumbnail.jpg"/&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p>I've found <a href="https://stackoverflow.com/questions/92427/apply-inline-css-to-an-asp-net-server-control">another question</a> that allows me to add inline style to a control, but I want to add a class to the img that asp:Hyperlink generates.</p>
  
  <p>Is it possible to do something similar to this answer:</p>
  
  <pre><code>myControl.Attributes.Add("style", "color:red");
  </code></pre>
  
  <p>Like, maybe?:</p>
  
  <pre><code>myControl.img.Attributes.Add("class", "blah");
  </code></pre>