Export (0) Print
Expand All

Panel.Direction Property

Gets or sets the direction in which to display controls that include text in a Panel control.

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

public virtual ContentDirection Direction { get; set; }
<asp:Panel Direction="ContentDirection" />

Property Value

Type: System.Web.UI.WebControls.ContentDirection
One of the ContentDirection enumeration values. The default is NotSet.

Use the Direction property to specify the display direction for controls that include text in a Panel control. This property is set using one of the ContentDirection enumeration values. The following table lists the possible values.

Value

Description

NotSet

The content direction is not set.

LeftToRight

The content direction is left to right.

RightToLeft

The content direction is right to left.

If you specify LeftToRight, child controls that include text display from left to right. If you specify RightToLeft, child controls that include text display right to left. Use RightToLeft to display text for languages that are written from right to left, such as Arabic or Hebrew.

NoteNote

This property is supported only on browsers that support HTML 4.0 or later.

The following code example demonstrates how to programmatically 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 the user selects from the list box. Note that this example uses English text. Therefore, 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 RightToLeft if you were displaying text for a left-to-right language.

NoteNote

The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see ASP.NET Web Forms Page Code Model.

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <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

    </script>
</head>
<body>
    <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"
            Rows="3"
            AutoPostBack="True"
            SelectionMode="Single"
            OnSelectedIndexChanged="ListBox1_SelectedIndexChanged"
            runat="server">
                <asp:ListItem>NotSet</asp:ListItem>
            <asp:ListItem>LeftToRight</asp:ListItem> 
            <asp:ListItem>RightToLeft</asp:ListItem>                               
        </asp:ListBox>

        <hr />              

        <asp:Panel ID="Panel1"
            Height="100px"
            Width="300px"
            BackColor="Aqua"           
            runat="server">            

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

            <asp:RadioButton id="Radio1"
                Text="C#" 
                Checked="False" 
                GroupName="RadioGroup1" 
                runat="server">
            </asp:RadioButton><br />

            <asp:RadioButton id="Radio2"
                Text="Visual Basic" 
                Checked="False" 
                GroupName="RadioGroup1" 
                runat="server">
            </asp:RadioButton><br />

            <asp:RadioButton id="Radio3"
                Text="C++" 
                Checked="False" 
                GroupName="RadioGroup1" 
                runat="server">
            </asp:RadioButton><br />           

        </asp:Panel>           

    </form>
</body>
</html>

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft