WebPart.AllowMinimize 属性

定义

获取或设置一个值,该值指示最终用户是否可以最小化 WebPart 控件。

public:
 virtual property bool AllowMinimize { bool get(); void set(bool value); };
[System.Web.UI.Themeable(false)]
[System.Web.UI.WebControls.WebParts.Personalizable(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared)]
public virtual bool AllowMinimize { get; set; }
[<System.Web.UI.Themeable(false)>]
[<System.Web.UI.WebControls.WebParts.Personalizable(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared)>]
member this.AllowMinimize : bool with get, set
Public Overridable Property AllowMinimize As Boolean

属性值

如果可以最小化 WebPart 控件,则为 true;否则为 false。 默认值是 true

属性

示例

下面的代码示例演示如何更改自定义 Web 部件控件的 属性的 AllowMinimize 默认设置,以便用户无法最小化该控件。 此示例假定使用自定义 WebPart 控件 ,该控件 TextDisplayWebPart可在类概述的 WebPart “示例”部分找到。

在网页的声明性标记中,在引用控件的 元素上 <aspSample:TextDisplayWebPart> ,注意 AllowMinimize="false" 属性,该属性隐藏控件谓词 WebPart 菜单中的最小化谓词,并阻止用户最小化控件。 在浏览器中加载页面,然后单击控件上的 WebPart 谓词菜单。 最小化谓词(通常出现在谓词菜单上)是隐藏的,因为你在控件的声明性标记中禁用了它。

<%@ page language="C#" %>
<%@ register tagprefix="aspSample" 
             Namespace="Samples.AspNet.CS.Controls" 
             Assembly="TextDisplayWebPartCS"%>

<!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 id="Head1" runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
  <form id="Form1" runat="server">
    <asp:webpartmanager id="WebPartManager1" runat="server" />
    <asp:webpartzone
      id="WebPartZone1"
      runat="server"
      title="Zone 1"
      PartChromeType="TitleAndBorder">
        <parttitlestyle font-bold="true" ForeColor="#3300cc" />
        <partstyle
          borderwidth="1px"   
          borderstyle="Solid"  
          bordercolor="#81AAF2" />
        <zonetemplate>
          <aspSample:TextDisplayWebPart 
            runat="server"   
            id="textwebpart" 
            title = "Text Content WebPart" 
            AllowMinimize="false" />
        </zonetemplate>
    </asp:webpartzone>
  </form>
</body>
</html>
<%@ page language="VB" %>
<%@ register tagprefix="aspSample" 
             Namespace="Samples.AspNet.VB.Controls" 
             Assembly="TextDisplayWebPartVB"%>

<!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 id="Head1" runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
  <form id="Form1" runat="server">
    <asp:webpartmanager id="WebPartManager1" runat="server" />
    <asp:webpartzone
      id="WebPartZone1"
      runat="server"
      title="Zone 1"
      PartChromeType="TitleAndBorder">
        <parttitlestyle font-bold="true" ForeColor="#3300cc" />
        <partstyle
          borderwidth="1px"   
          borderstyle="Solid"  
          bordercolor="#81AAF2" />
        <zonetemplate>
          <aspSample:TextDisplayWebPart 
            runat="server"   
            id="textwebpart" 
            title = "Text Content WebPart" 
            AllowMinimize="false" />
        </zonetemplate>
    </asp:webpartzone>
  </form>
</body>
</html>

注解

AllowMinimize属性(如果设置为 false),则阻止最终用户最小化控件,并且用户界面 (UI) 最小化控件不会显示在控件的标题栏中。 在 Web 部件术语中,当 属性 AllowMinimize 设置为 false时,最小化谓词不会显示在控件的谓词菜单上。

当用户最小化控件时,它会将控件的大小缩小到仅显示控件标题栏和标题的一部分的最小区域。

无法通过主题或样式表主题设置此属性。 有关详细信息,请参阅 ThemeableAttributeASP.NET 主题和皮肤

此属性的个性化设置范围设置为 Shared ,并且只能由授权用户修改。 有关详细信息,请参阅 PersonalizableAttributeWeb 部件个性化概述

适用于

另请参阅