Resize images to fit image control in asp.net javascript

Posted by tszoro on Stack Overflow See other posts from Stack Overflow or by tszoro
Published on 2012-10-13T15:20:46Z Indexed on 2012/10/13 15:37 UTC
Read the original article Hit count: 108

I change an image in the header based on which menu item is selected. The problem is that the image stretches in the image control. I want it to automatically zoom without distorting the image. Is this possible.

Note: The images reside in an images folder and are not all the same size.

Javascript

<script type="text/javascript">

    function ChangeProjectImage(imgpath) {
        var img1 = document.getElementById("Image2")
        img1.src = imgpath;
    }

</script>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about ASP.NET