asp.net.ph

HtmlImage.Width Property

System.Web.UI.HtmlControls Namespace   HtmlImage Class


Sets or retrieves the width of the image.

Syntax


Inline <img width = intWidth | %Width ... >
Script HtmlImage.Width [ = intWidth | %Width ]

Property Value


intWidth Integer specifying the width, in pixels.
%Width Value expressed as a percentage of the parent object's width.

The property is read/write with no default value.

Remarks

The Width and Height properties of an HtmlImage can be used two ways:

  • to send the image size specifications to the browser, or
  • to scale the image.

Width and Height give browsers an idea of the size of an image so that they may reserve space for it and continue rendering the document while waiting for the image data. This displays the Web page faster since the browser does not need to recalculate the positions of other elements on the page as the image loads.

When using values that are different from the natural size of the image, the browser overrides the physical image size in favor of these values and the image is resized accordingly. This method for scaling an image is not recommended, though, as it takes longer for the page to display. Instead, physically resize the image in a graphics editor to the size you need.

By default, Width is expressed in pixels, but can also be expressed as a percentage of the containing object, which typically is the page. Widths expressed as percentages are based on the horizontal space currently available, not on the natural size of the image. Note, though, that this property always retrieves the width in pixels.

Example

The below code shows how to declaratively set the Width property of an HtmlImage control at design time.

<img src="~/shared/aspxtreme.jpg" width=100 height=30 border=0 
   alt="Simply awesome" align="right" runat="server" />
See Also

HtmlImage Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph