WebPartZone Constructor

Definition

Initializes a new instance of the WebPartZone class.

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

Examples

The following code example demonstrates the use of a constructor on a custom WebPartZone class to set several base properties for the zone. This approach could be useful if you want to create a custom WebPartZone control that has specific behaviors and appearance. The 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

Remarks

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.

Applies to

See also