Sunday, August 15, 2010

How to zoom in/out an image using asp.net

It is necessary to hold width and height in ViewState variables in-order to hold width and height values during postbacks.
Example:
<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head2" runat="server">    
    <script runat="server">
        private double swift = 10;
        public void ChangeSize(object sender, EventArgs e)
        {
            double w = this.imgDisplay.Width.Value;
            double h = this.imgDisplay.Height.Value;
            Button button = sender as Button;
            if (button.CommandName.Equals("ZI"))
            {
                h += swift;
                w += swift;
            }
            else if (button.CommandName.Equals("ZO"))
            {
                w -= swift;
                h -= swift;
            }
            this.imgDisplay.Height = new Unit(h);
            this.imgDisplay.Width = new Unit(w);
        }        
    </script>
</head>
<body>    
    <form id="form2" runat="server">  
        <asp:Image runat="server" ID="imgDisplay" ImageUrl="~/Images/Charith.jpg" Width="100px" Height="100px" />
        <asp:Button runat="server" ID="btnZoomIn" OnClick="ChangeSize" Text="+" CommandName="ZI" />
        <asp:Button runat="server" ID="btnZoomOut" OnClick="ChangeSize" Text="-" CommandName="ZO" />        
    </form>
</body>

No comments:

iPhone Launch Screen Sizes

iPhone Portrait iOS 8 Retina HT 5.5 = 1242 X 2208 Retna HD 4.7 = 750 X 1134 iPhone Landscape iOS 8 Retina HD 5.5  2208 X 1242 iPho...