WebPartZone 构造函数

定义

初始化 WebPartZone 类的新实例。Initializes a new instance of the WebPartZone class.

public:
 WebPartZone();
public WebPartZone ();
Public Sub New ()

示例

下面的代码示例演示如何在自定义类上使用构造函数 WebPartZone 来设置区域的几个基属性。The following code example demonstrates the use of a constructor on a custom WebPartZone class to set several base properties for the zone. 如果要创建 WebPartZone 具有特定行为和外观的自定义控件,此方法可能会很有用。This approach could be useful if you want to create a custom WebPartZone control that has specific behaviors and appearance. 此示例的完整代码包括自定义类和承载控件的 .aspx 页,位于类概述主题的 "示例" 部分 WebPartZoneThe full code for the example, including both the custom class and an .aspx page to host the control, is found in the Example section of the WebPartZone class overview topic.

using System;
using System.Collections;
using System.ComponentModel;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace Samples.AspNet.CS.Controls
{
  [AspNetHostingPermission(SecurityAction.Demand, 
    Level=AspNetHostingPermissionLevel.Minimal)]
  [AspNetHostingPermission(SecurityAction.InheritanceDemand, 
    Level=AspNetHostingPermissionLevel.Minimal)]
  public class MyWebPartZone : WebPartZone
  {
    public MyWebPartZone()
    {
      base.VerbButtonType = ButtonType.Button;
      base.CloseVerb.Enabled = false;
    }
  }
}
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.WebControls
Imports System.Web.UI
Imports System.Web
Imports System.Security.Permissions
Imports System.ComponentModel
Imports System.Collections
Namespace Samples.AspNet.VB.Controls
  

<AspNetHostingPermission(SecurityAction.Demand, _
  Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(SecurityAction.InheritanceDemand, _
  Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class MyWebPartZone
  Inherits WebPartZone
  
  Public Sub New()
    MyBase.New
    MyBase.VerbButtonType = ButtonType.Button
    MyBase.CloseVerb.Enabled = false
  End Sub
End Class
  
End Namespace

注解

WebPartZone 方法是一个无参数的构造函数,不会设置任何值。The WebPartZone method is a parameterless constructor and does not set any values. 但是,派生类可以使用构造函数来设置基本区域属性,以创建自定义区域控件的标准行为和外观。However, derived classes can use the constructor to set base zone properties, to create standard behaviors and appearance for a custom zone control.

适用于