This documentation is archived and is not being maintained.

ContentDirection Enumeration

Represents the direction in which to display controls that include text in a container control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public enum ContentDirection

Member nameDescription
NotSetNot set.
LeftToRightLeft to right.
RightToLeftRight to left.

The ContentDirection enumeration represents the direction in which to display controls that include text in a container control. Controls, such as the Panel and WebPart controls, have properties that use the ContentDirection enumeration values to specify the direction in which to display child controls that include text.

If you specify the LeftToRight value, child controls that include text display text from left to right and justify the text on the left side of the container control. If you specify the RightToLeft value, child controls that include text display text from right to left and justify the text on the right side of the container control. Use the RightToLeft value to display text for languages that are written from right to left, such as Arabic and Hebrew.

The following code example demonstrates how to use the ContentDirection enumeration to set the Direction property. A ListBox control is populated with the ContentDirection enumeration values. The display direction of the label and radio buttons in the panel change based on the value that the user selects from the list box. Because this example uses English text, when the RightToLeft value is selected, the text is justified on the right side of the Panel control, but the left-to-right order of the English text is maintained. In a real-world application, you would not set the Direction property to the RightToLeft value, if you were displaying text for a language that uses left-to-right order.

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="" >
    <title>Panel.Direction Property Example</title>
<script runat="server">

        Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)

            ' Determine which list item was clicked. 
            ' Change the display direction of content in the panel. 
            Select Case (ListBox1.SelectedIndex)
                Case 0
                    Panel1.Direction = ContentDirection.NotSet
                Case 1
                    Panel1.Direction = ContentDirection.LeftToRight
                Case 2
                    Panel1.Direction = ContentDirection.RightToLeft
                Case Else 
                    Throw New Exception("You did not select a valid list item.")
            End Select 

        End Sub

    <form id="Form1" runat="server">

        <h3>Panel.Direction Property Example</h3>

        <h4>Select the content display direction for the 
        controls in the panel.</h4>

        <asp:ListBox ID="ListBox1"

        <hr />              

        <asp:Panel ID="Panel1"

            <asp:Label ID="Label1"
                Text = "Select a programming language"
            </asp:Label><br /><br />

            <asp:RadioButton id="Radio1"
            </asp:RadioButton><br />

            <asp:RadioButton id="Radio2"
                Text="Visual Basic" 
            </asp:RadioButton><br />

            <asp:RadioButton id="Radio3"
            </asp:RadioButton><br />           



Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0