Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
Sample code for WebResizingExtender
posted

Does anyone have asp.net code sample that, using your WebResizingExtender, resizes a regular System.Web.UI.WebControl.Image component and retains the original aspect ratio?  I can't figure out how to resize pictures without losing the aspect ratio.

Parents
  • 16310
    Offline posted

    Hello Tappie,

    Thank for posting in the Infragistics community !

    It seems that there is no such property to support keeping the aspect ratio out of the box. Considering this I suggest that you handle the OnClientResize event and change the image height with the same ratio the width has changed with. Here is a sample code:

    <img src=http://es.infragistics.com/samplesbrowser/samplescommon/aspnet/WebResizingExtender/Display/ResizingImages/image9.jpg alt="Image" id="Image1" runat="server" width="320" height="240" />

    <igui:WebResizingExtender ID="resizer" TargetControlID="Image1" OnClientResize="Resize" runat="server" />

    ................

    function Resize(e, args) {

         var widthChangeRatio = args.getWidth() / args.getOldWidth();

               args.setHeight(args.getOldHeight() * widthChangeRatio);

    }


    Please let me know if you have further questions on the matter.

Reply Children
No Data