System.Web.UI.WebControls Namespace Image Class
Sets or retrieves the alignment of the image in relation to other Web page elements.
Inline |
<asp:image imagealign = enumValue ... > |
Script |
Image.ImageAlign [ = enumValue ] |
The property is read/write with a default value of Both.
Use the ImageAlign property to specify or determine the alignment of the image in relation to other elements on the Web page.
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
Image Members ImageAlign Enum