This documentation is archived and is not being maintained.

HtmlImage.Align Property

Gets or sets the alignment of the image relative to other Web page elements.

[Visual Basic]
Public Property Align As String
[C#]
public string Align {get; set;}
[C++]
public: __property String* get_Align();
public: __property void set_Align(String*);
[JScript]
public function get Align() : String;
public function set Align(String);

Property Value

A string that specifies the alignment of the image relative to other Web page elements.

Remarks

Use this property to specify the alignment of the image with respect to other elements on the Web page.

The following table represents the possible values.

Value Description
left The image is aligned on the left side of the Web page.
center The image is aligned in the center of the Web page.
right The image is aligned on the right side of the Web page.
top Other elements in the Web page are aligned with the top edge of the image.
middle Other elements in the Web page are aligned with the middle of the image.
bottom Other elements in the Web page are aligned with the bottom edge of the image.
Note   The center value may not work on all browsers. To center an image, wrap the HtmlImage control inside paragraph tags that contain the align attribute set to center (<p align= "center">).

Example

[Visual Basic, C#, JScript] The following example demonstrates how to use the Align property to specify the alignment of the image on the Web page.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>

<html>
 <head>
 
 </head>
 
 <body>
 
    <form runat="server">
 
       <h3>HtmlImage Example</h3>
     
       <img id ="Image1"
            Src="image1.jpg"
            Width="500"
            Height="226"
            Alt="Image 1"
            Border="5"
            Align="left" 
            runat=server/>
    
    </form>
 
 </body>
 </html>

[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
 <head>
 
 </head>
 
 <body>
 
    <form runat="server">
 
       <h3>HtmlImage Example</h3>
     
       <img id ="Image1"
            Src="image1.jpg"
            Width="500"
            Height="226"
            Alt="Image 1"
            Border="5"
            Align="left" 
            runat=server/>
    
    </form>
 
 </body>
 </html>

[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>
<html>
 <head>
 
 </head>
 
 <body>
 
    <form runat="server">
 
       <h3>HtmlImage Example</h3>
     
       <img id ="Image1"
            Src="image1.jpg"
            Width="500"
            Height="226"
            Alt="Image 1"
            Border="5"
            Align="left" 
            runat=server/>
    
    </form>
 
 </body>
 </html>

[Visual Basic, C#, JScript] The following example demonstrates how to center an image on the Web page by wrapping the HtmlImage control inside paragraph tags with the align attribute set to "center".

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
 <head>
 
 </head>
 
 <body>
 
    <form runat="server">
 
       <h3>HtmlImage Example</h3>
 
       <p align="center">
     
          <img id="Image1"
               Src="image1.jpg"
               Width="500"
               Height="226"
               Alt="Image 1"
               Border="5"
               runat=server/>
 
       </p>
 
    </form>
 
 </body>
 </html>

[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
 <head>
 
 </head>
 
 <body>
 
    <form runat="server">
 
       <h3>HtmlImage Example</h3>
 
       <p align="center">
     
          <img id="Image1"
               Src="image1.jpg"
               Width="500"
               Height="226"
               Alt="Image 1"
               Border="5"
               runat=server/>
 
       </p>
 
    </form>
 
 </body>
 </html>

[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>
<html>
 <head>
 
 </head>
 
 <body>
 
    <form runat="server">
 
       <h3>HtmlImage Example</h3>
 
       <p align="center">
     
          <img id="Image1"
               Src="image1.jpg"
               Width="500"
               Height="226"
               Alt="Image 1"
               Border="5"
               runat=server/>
 
       </p>
 
    </form>
 
 </body>
 </html>

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

HtmlImage Class | HtmlImage Members | System.Web.UI.HtmlControls Namespace

Show: