Last post Nov 29, 2008 10:58 AM by SGWellens
Nov 27, 2008 06:05 AM|Bluebird1984|LINK
My back end C# code gets the URL of an Image and the image is displayed in the ASPX page using an Image Control. The Image needs to be displayed within a certain size, for example the image needs to be contained within a 200px X 200px DIV. I've tried setting
the width and height properties of the image control but this does not maintain the aspec ratio of the image when it's loaded. Is there a way I can dynamically display an image and maintain it's aspec ratio?
Nov 27, 2008 12:49 PM|SGWellens|LINK
If you only set one dimension of an ImageControl, the aspect ratio is maintained.
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/April.JPG" />
<asp:Image ID="Image2" runat="server" Height="50px" ImageUrl="~/Images/April.JPG" />
<asp:Image ID="Image3" runat="server" Width="30px" ImageUrl="~/Images/April.JPG" />
Nov 28, 2008 04:44 AM|Bluebird1984|LINK
thanks very much, works great
Nov 29, 2008 10:10 AM|xoro|LINK
I think it's not a good idea to resize image by specify Width or Heigh on a Image directly .. You might use an HttpHandler to reduce Image Size and Maintain Aspet Ratio.
Take a look at this thread : http://forums.asp.net/t/1349134.aspx
Nov 29, 2008 10:58 AM|SGWellens|LINK
I think it's not a good idea to resize image by specify Width or Heigh on a Image directly