title: Dynamically change an images height using codebehind
body: <p>I want to re-size an asp:image using code behind. I'm gonna re-size the image depending on its height so it can fit into place. So far i have</p>
  
  <pre><code>        Image img1 = ((Image)e.Item.FindControl("prodImage"));
          int finalWidth = Convert.ToInt32(img1.Width);
          int maxWidth = 20;
  
          if (finalWidth &gt; maxWidth)
          {
              resize
          }
          else
          {
              dont resize
          }
  </code></pre>
  
  <p>I am getting a conversion error because img1.width is a web unit. I tried but couldnt cast as an int or cast the int as a unit.</p>
  
  <p>Thanks to anyone who can help</p>