locked
Image Width RRS feed

  • Question

  • User-710761916 posted

    How can I convert an image's width to an integer?

    When I try something like: "if image1.width = 5" it works fine. However, when I try something like: "if image1.width > 5" it gives me the wrong type of variable error. It does the same for tables... and everything else if I where to guess.

    Any Ideas?

    Thursday, July 3, 2008 8:56 PM

All replies

  • User187056398 posted

    The Width property is type Unit, you can access it like this:


            System.Web.UI.WebControls.Image MyImage = new System.Web.UI.WebControls.Image();
            MyImage.Width = 100;

            if (MyImage.Width.Value > 99)
                Response.Write("Got it");

    Unit can be in pixels, percentage, etc.

    Thursday, July 3, 2008 9:30 PM