Bewerken

Share via


WebPartZoneBase.LayoutOrientation Property

Definition

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

public:
 virtual property System::Web::UI::WebControls::Orientation LayoutOrientation { System::Web::UI::WebControls::Orientation get(); void set(System::Web::UI::WebControls::Orientation value); };
public virtual System.Web.UI.WebControls.Orientation LayoutOrientation { get; set; }
member this.LayoutOrientation : System.Web.UI.WebControls.Orientation with get, set
Public Overridable Property LayoutOrientation As Orientation

Property Value

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

Exceptions

The value is not one of the enumerated Orientation values.

Examples

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.

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

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);
}
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

Remarks

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.

Internet Explorer can affect the height of a WebPart control, and the height of the zone that contains it. Internet Explorer renders web pages either in compatibility mode (backward compatible with previous browser versions), or in standards mode (determined by the presence of a DOCTYPE declaration in the page). For information about these modes, see the DHTML compatMode property. When Internet Explorer renders a page in standards mode, in some scenarios it does not resize cells in tables, even when a cell's HTML markup is <td height="100%">. As a result, WebPart controls and their containing zone are rendered so that the controls do not stretch to the full height of the zone.

This type of rendering occurs in two cases.

  • When a zone's LayoutOrientation property is set to Vertical, and you explicitly set the height on the zone. To enable controls to fill the full height of the zone, do not specify the height of a horizontal zone.

  • When a zone's LayoutOrientation property is set to Horizontal, and you do not explicitly set the height of the zone (or of the contained controls). To enable controls to fill the full height of the zone, set the height of the zone or of the controls in a vertical zone.

The code example in this topic demonstrates normal usage of the LayoutOrientation property. For a code example that demonstrates the height-related rendering issue and how to work around it, see the Height property.

Applies to

See also