System.Web.UI.WebControls Namespace
Specifies the alignment of an image in relation to adjacent text.
Member Name |
Description |
AbsBottom |
The bottom of the image is aligned with the bottom of the largest element on the same line. |
AbsMiddle |
The middle of the image is aligned with the middle of the largest element on the same line. |
Baseline |
The bottom of the image is aligned with the bottom of the first line of wrapping text. |
Bottom |
The bottom of the image is aligned with the bottom of the first line of wrapping text. |
Left |
The image is aligned to the left with text wrapping on the right. |
Middle |
The middle of the image is aligned with the bottom of the first line of wrapping text. |
NotSet |
The alignment is not set. |
Right |
The image is aligned to the right with text wrapping on the left. |
TextTop |
The image is aligned with the top of the highest text on the same line. |
Top |
The image is aligned with the top of the highest element on the same line. |
The ImageAlign enumeration represents the alignment options for an image relative to adjoining text on a Web page.
The following example shows how to declaratively set the ImageAlign property of an Image control at design time.
<asp:image id = "myImg" runat = "server"
imageurl = "~/shared/images/earth.gif"
imagealign = "right" />
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 ImageButton