asp.net.ph

Image.ImageAlign Property

System.Web.UI.WebControls Namespace   Image Class


Sets or retrieves the alignment of the image in relation to other Web page elements.

Syntax


Inline <asp:image imagealign = enumValue ... >
Script Image.ImageAlign [ = enumValue ]

Property Value


enumValue One of the ImageAlign enum values.

The property is read/write with a default value of Both.

Exceptions


Exception Type Condition
ArgumentException Occurs when the specified value is not one of the ImageAlign values.

Remarks

Use the ImageAlign property to specify or determine the alignment of the image in relation to other elements on the Web page.

Example

The following example shows how to declaratively set the ImageAlign property of an Image control at design time.

<asp:image imageurl = "~/shared/aspxtreme.jpg" width=100 height=30 border=0 
   alternatetext = "Simply awesome" imagealign = "right" runat = "server" />

The example below shows how to programmatically set the ImageAlign property at run time, depending on user input. The code also demonstrates how simple it is to retrieve the available system alignment styles and dynamically add each to a selectable list.

void Page_Load ( Object src, EventArgs e ) {
   if ( !IsPostBack ) {
      ICollection alignEnum = 
         TypeDescriptor.GetConverter ( typeof ( ImageAlign ) ).GetStandardValues ( );
      foreach ( ImageAlign a in alignEnum ) {
         alignSelect.Items.Add ( a.ToString ( ) );
      }
   }
   theImg.ImageAlign = ( ImageAlign ) alignSelect.SelectedIndex;
}

 Show me 

See Also

Image Members   ImageAlign Enum 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