WebPartZoneBase.LayoutOrientation 属性

定义

获取或设置指示区域中的控件是垂直排列还是水平排列的值。

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

属性值

确定区域中控件的排列方式的 Orientation 值。 默认方向为 Vertical

例外

该值不是枚举的 Orientation 值之一。

示例

下面的代码示例演示了在 控件上WebPartZone以声明方式和编程方式使用 LayoutOrientation 属性。 有关完整的代码示例,包括代码隐藏源文件和包含此代码中的区域的.aspx页,请参阅 WebPartZoneBase 类概述。

请注意, LayoutOrientation 属性在声明性标记中分配了一个值。 将页面加载到浏览器中后,此值会影响 WebPartZone1。 区域中的 Web 部件控件水平呈现。

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

可以单击“ 切换布局方向 ”按钮更改区域的方向。 用于切换方向的代码出现在分部类的以下代码示例中。

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

注解

属性 LayoutOrientation 涉及 Web 部件控件在区域中的布局方式。 使用默认 Vertical 方向时,控件按从上到下排列,根据 ZoneIndex 每个控件的值呈现。 Horizontal对于方向,控件将并排排列,具体取决于区域的宽度。

Internet Explorer 可能会影响控件的高度 WebPart 以及包含控件的区域的高度。 Internet Explorer 在兼容模式下呈现网页 (与以前的浏览器版本向后兼容) ,或在标准模式下呈现网页 (由页面) 中是否存在 DOCTYPE 声明决定。 有关这些模式的信息,请参阅 DHTML compatMode 属性。 当 Internet Explorer 以标准模式呈现页面时,在某些情况下,即使单元格的 HTML 标记为 <td height="100%">,它也不会调整表格中的单元格大小。 因此, WebPart 将呈现控件及其包含区域,以便控件不会拉伸到区域的完整高度。

这种类型的呈现在两种情况下发生。

  • 如果区域的 LayoutOrientation 属性设置为 Vertical,并且显式设置区域的高度。 若要使控件能够填充区域的完整高度,请不要指定水平区域的高度。

  • 当区域的 LayoutOrientation 属性设置为 Horizontal时,您不显式设置区域的高度 (或) 所包含的控件的高度。 若要使控件能够填充区域的完整高度,请设置区域或垂直区域中控件的高度。

本主题中的代码示例演示 属性的 LayoutOrientation 正常用法。 有关演示与高度相关的呈现问题的代码示例及其解决方法,请参阅 Height 属性。

适用于

另请参阅