Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Previous Versions
.NET Framework 2.0
 LayoutOrientation Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
.NET Framework Class Library
WebPartZoneBase.LayoutOrientation Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets a value that indicates whether controls in a zone are arranged vertically or horizontally.

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

Visual Basic (Declaration)
Public Overridable Property LayoutOrientation As Orientation
Visual Basic (Usage)
Dim instance As WebPartZoneBase
Dim value As Orientation

value = instance.LayoutOrientation

instance.LayoutOrientation = value
C#
public virtual Orientation LayoutOrientation { get; set; }
C++
public:
virtual property Orientation LayoutOrientation {
    Orientation get ();
    void set (Orientation value);
}
J#
/** @property */
public Orientation get_LayoutOrientation ()

/** @property */
public void set_LayoutOrientation (Orientation value)
JScript
public function get LayoutOrientation () : Orientation

public function set LayoutOrientation (value : Orientation)

Property Value

An Orientation value that determines how controls in a zone are arranged. The default orientation is Vertical.
Exception typeCondition

ArgumentOutOfRangeException

The value is not one of the enumerated Orientation values.

The LayoutOrientation property concerns how Web Parts controls are laid out in a zone. With the default Vertical orientation, the controls are rendered in a top-to-bottom arrangement, according to the ZoneIndex value of each control. With a Horizontal orientation, the controls are arranged side by side, subject to the width of the zone.

The following code example demonstrates the declarative and programmatic use of the LayoutOrientation property on a WebPartZone control. For the full code example, including the code-behind source file and the .aspx page that contains the zone in this code, see the WebPartZoneBase class overview.

Notice that the LayoutOrientation property has a value assigned to it in the declarative markup. This value impacts WebPartZone1, after you load the page into a browser. The Web Parts controls in the zone are rendered horizontally.

Visual Basic
<asp:WebPartZone 
  ID="WebPartZone1" 
  Runat="server"
  LayoutOrientation="Vertical" >
  <EditVerb Text="Edit WebPart" />
  <SelectedPartChromeStyle BackColor="LightBlue" />
  <ZoneTemplate>
    <asp:BulletedList 
      ID="BulletedList1" 
      Runat="server"
      DisplayMode="HyperLink" 
      Title="Favorite Links" >
      <asp:ListItem Value="http://msdn.microsoft.com">
        MSDN
      </asp:ListItem>
      <asp:ListItem Value="http://www.asp.net">
        ASP.NET
      </asp:ListItem>
      <asp:ListItem Value="http://www.msn.com">
        MSN
      </asp:ListItem>
    </asp:BulletedList>
    <asp:Calendar ID="Calendar1" Runat="server" 
      Title="My Calendar" />
  </ZoneTemplate>
</asp:WebPartZone>
C#
<asp:WebPartZone 
  ID="WebPartZone1" 
  Runat="server"
  LayoutOrientation="Vertical" >
  <EditVerb Text="Edit WebPart" />
  <SelectedPartChromeStyle BackColor="LightBlue" />
  <ZoneTemplate>
    <asp:BulletedList 
      ID="BulletedList1" 
      Runat="server"
      DisplayMode="HyperLink" 
      Title="Favorite Links" >
      <asp:ListItem Value="http://msdn.microsoft.com">
        MSDN
      </asp:ListItem>
      <asp:ListItem Value="http://www.asp.net">
        ASP.NET
      </asp:ListItem>
      <asp:ListItem Value="http://www.msn.com">
        MSN
      </asp:ListItem>
    </asp:BulletedList>
    <asp:Calendar ID="Calendar1" Runat="server" 
      Title="My Calendar" />
  </ZoneTemplate>
</asp:WebPartZone>

You can click the Toggle Layout Orientation button to change the orientation of the zone. The code to toggle the orientation occurs in the following code example from the partial class.

Visual Basic
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) 
  If WebPartZone1.LayoutOrientation = Orientation.Vertical Then
      WebPartZone1.LayoutOrientation = Orientation.Horizontal
  Else
      WebPartZone1.LayoutOrientation = Orientation.Vertical
  End If
  Page_Load(sender, e)
End Sub 
C#
protected void Button2_Click(object sender, EventArgs e)
{
  if (WebPartZone1.LayoutOrientation == Orientation.Vertical)
    WebPartZone1.LayoutOrientation = Orientation.Horizontal;
  else
    WebPartZone1.LayoutOrientation = Orientation.Vertical;
  Page_Load(sender, e);
}

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

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

.NET Framework

Supported in: 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker