WebPartZone 构造函数

定义

初始化 WebPartZone 类的新实例。

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

示例

下面的代码示例演示如何在自定义 WebPartZone 类上使用构造函数来设置区域的多个基属性。 如果要创建具有特定行为和外观的自定义 WebPartZone 控件,此方法可能很有用。 该示例的完整代码(包括自定义类和用于托管控件的.aspx页)位于类概述主题的 WebPartZone “示例”部分。

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 无参数构造函数,不设置任何值。 但是,派生类可以使用 构造函数设置基区域属性,以便为自定义区域控件创建标准行为和外观。

适用于

另请参阅