WebPartZone 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 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 無參數建構函式,而且不會設定任何值。 不過,衍生類別可以使用 建構函式來設定基底區域屬性,以建立自訂區域控制項的標準行為和外觀。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應