Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

HtmlTable.Align Property

Gets or sets the alignment of the HtmlTable control in relation to other elements on the Web page.

[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

The alignment of the HtmlTable control in relation to other elements on the Web page. The default value is String.Empty, which indicates that this property is not set.

Remarks

Use the Align property to specify the alignment of the HtmlTable control in relation to other elements on the Web page.

Note   This property does not control the alignment of the contents in the cells of the HtmlTable control. To control the alignment of contents of an individual cell, use the Align and VAlign properties of the HtmlTableCell class. You can also control the alignment of contents of the cells in an entire row by using the Align and VAlign properties of the HtmlTableRow class.

The following table lists the values that can be used for this property.

Value Description
Left Aligns the HtmlTable control on the left edge of the Web page.
Center Aligns the HtmlTable control in the middle of the Web page.
Right Aligns the HtmlTable control on the right edge of the Web page.
Note   If you specify Left or Right alignment, other elements on the Web page will wrap to the right and left of the HtmlTable control, respectively. If you specify Center alignment, no wrapping occurs and other elements appear below the control.

Example

[Visual Basic, C#, JScript] The following example demonstrates how to use the Align property to specify the alignment of the HtmlTable control in relation to other elements on the Web page.

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

<html>
<head>

   <script runat="server">

      Sub Button_Click(sender As Object, e As EventArgs ) 

         Table1.CellSpacing = CInt(SpacingSelect.Value)
         Table1.CellPadding = CInt(PaddingSelect.Value)
         Table1.Align = AlignSelect.Value

      End Sub

   </script>

</head>
<body>

   <form runat="server">

      <h3>HtmlTable Example</h3>

      <table id="Table1" 
             Border="1" 
             BorderColor="black" 
             runat="server">

         <tr>
            <th>
               Column 1
            </th>
            <th>
               Column 2
            </th>
            <th>
               Column 3
            </th>
         </tr>
         <tr>
            <td>
               Cell 1
            </td>
            <td>
               Cell 2
            </td>
            <td>
               Cell 3
            </td>
         </tr>
         <tr>
            <td>
               Cell 4
            </td>
            <td>
               Cell 5
            </td>
            <td>
               Cell 6
            </td>
         </tr>

      </table>
      
      <br><br><br><br><br><br><br><br>
      
      <hr>

      Select the display settings: <br><br>

      Align:
      <select id="AlignSelect" 
              runat="server">

         <option Value="Left">Left</option>
         <option Value="Center">Center</option>
         <option Value="Right">Right</option>
        
      </select>

      &nbsp;&nbsp;

      CellPadding:
      <select id="PaddingSelect" 
              runat="server">

         <option Value="0">0</option>
         <option Value="1">1</option>
         <option Value="2">2</option>
         <option Value="3">3</option>
         <option Value="4">4</option>
         <option Value="5">5</option>

      </select>

      &nbsp;&nbsp;

      CellSpacing:
      <select id="SpacingSelect" 
              runat="server">

         <option Value="0">0</option>
         <option Value="1">1</option>
         <option Value="2">2</option>
         <option Value="3">3</option>
         <option Value="4">4</option>
         <option Value="5">5</option>

      </select>
       
      <br><br>
  
      <input type="button" 
             value="Generate Table"
             OnServerClick = "Button_Click" 
             runat="server"/>

   </form>

</body>
</html>

[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">

      void Button_Click(Object sender, EventArgs e) 
      {

         Table1.CellSpacing = Convert.ToInt32(SpacingSelect.Value);
         Table1.CellPadding = Convert.ToInt32(PaddingSelect.Value);
         Table1.Align = AlignSelect.Value;

      }

   </script>

</head>
<body>

   <form runat="server">

      <h3>HtmlTable Example</h3>

      <table id="Table1" 
             Border="1" 
             BorderColor="black" 
             runat="server">

         <tr>
            <th>
               Column 1
            </th>
            <th>
               Column 2
            </th>
            <th>
               Column 3
            </th>
         </tr>
         <tr>
            <td>
               Cell 1
            </td>
            <td>
               Cell 2
            </td>
            <td>
               Cell 3
            </td>
         </tr>
         <tr>
            <td>
               Cell 4
            </td>
            <td>
               Cell 5
            </td>
            <td>
               Cell 6
            </td>
         </tr>

      </table>
      
      <br><br><br><br><br><br><br><br>
      
      <hr>

      Select the display settings: <br><br>

      Align:
      <select id="AlignSelect" 
              runat="server">

         <option Value="Left">Left</option>
         <option Value="Center">Center</option>
         <option Value="Right">Right</option>
        
      </select>

      &nbsp;&nbsp;

      CellPadding:
      <select id="PaddingSelect" 
              runat="server">

         <option Value="0">0</option>
         <option Value="1">1</option>
         <option Value="2">2</option>
         <option Value="3">3</option>
         <option Value="4">4</option>
         <option Value="5">5</option>

      </select>

      &nbsp;&nbsp;

      CellSpacing:
      <select id="SpacingSelect" 
              runat="server">

         <option Value="0">0</option>
         <option Value="1">1</option>
         <option Value="2">2</option>
         <option Value="3">3</option>
         <option Value="4">4</option>
         <option Value="5">5</option>

      </select>
       
      <br><br>
  
      <input type="button" 
             value="Generate Table"
             OnServerClick = "Button_Click" 
             runat="server"/>

   </form>

</body>
</html>

[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">

      function Button_Click(sender : Object, e : EventArgs) 
      {

         Table1.CellSpacing = Convert.ToInt32(SpacingSelect.Value);
         Table1.CellPadding = Convert.ToInt32(PaddingSelect.Value);
         Table1.Align = AlignSelect.Value;

      }

   </script>

</head>
<body>

   <form runat="server">

      <h3>HtmlTable Example</h3>

      <table id="Table1" 
             Border="1" 
             BorderColor="black" 
             runat="server">

         <tr>
            <th>
               Column 1
            </th>
            <th>
               Column 2
            </th>
            <th>
               Column 3
            </th>
         </tr>
         <tr>
            <td>
               Cell 1
            </td>
            <td>
               Cell 2
            </td>
            <td>
               Cell 3
            </td>
         </tr>
         <tr>
            <td>
               Cell 4
            </td>
            <td>
               Cell 5
            </td>
            <td>
               Cell 6
            </td>
         </tr>

      </table>
      
      <br><br><br><br><br><br><br><br>
      
      <hr>

      Select the display settings: <br><br>

      Align:
      <select id="AlignSelect" 
              runat="server">

         <option Value="Left">Left</option>
         <option Value="Center">Center</option>
         <option Value="Right">Right</option>
        
      </select>

      &nbsp;&nbsp;

      CellPadding:
      <select id="PaddingSelect" 
              runat="server">

         <option Value="0">0</option>
         <option Value="1">1</option>
         <option Value="2">2</option>
         <option Value="3">3</option>
         <option Value="4">4</option>
         <option Value="5">5</option>

      </select>

      &nbsp;&nbsp;

      CellSpacing:
      <select id="SpacingSelect" 
              runat="server">

         <option Value="0">0</option>
         <option Value="1">1</option>
         <option Value="2">2</option>
         <option Value="3">3</option>
         <option Value="4">4</option>
         <option Value="5">5</option>

      </select>
       
      <br><br>
  
      <input type="button" 
             value="Generate Table"
             OnServerClick = "Button_Click" 
             runat="server"/>

   </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

HtmlTable Class | HtmlTable Members | System.Web.UI.HtmlControls Namespace | CellSpacing | CellPadding | HtmlTableCell | HtmlTableCell.Align | HtmlTableCell.VAlign | HtmlTableRow | HtmlTableRow.Align | HtmlTableRow.VAlign

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.