PersistChildrenAttribute コンストラクタとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > PersistChildrenAttribute コンストラクタの意味・解説 

PersistChildrenAttribute コンストラクタ (Boolean)

入れ子になった内容入れ子になったコントロールとして保持するかどうかを示すブール値を使用して、PersistChildrenAttribute クラス新しインスタンス初期化します。

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

Dim persist As Boolean

Dim instance As New PersistChildrenAttribute(persist)
public PersistChildrenAttribute (
    bool persist
)
public:
PersistChildrenAttribute (
    bool persist
)
public PersistChildrenAttribute (
    boolean persist
)
public function PersistChildrenAttribute (
    persist : boolean
)

パラメータ

persist

入れ子になった内容入れ子になったコントロールとして保持する場合trueそれ以外場合false

使用例使用例

CollectionPropertyControl というカスタム サーバー コントロールに対して PersistChildrenAttribute 属性適用する方法次のコード例示します

このコード例は、PersistChildrenAttribute クラストピック取り上げているコード例一部分です。

' Use the PersistChildren attribute to set the Persist
' property to false so that none of this class's
' child controls will be persisted as controls. They will
' be persisted only as child elements of this class.
' If you set the PersistChildren attribute to true, or if you
' do not include this attribute when you create a control,
' the child controls will be persisted as controls.
<PersistChildren(False)>  _
<AspNetHostingPermission(SecurityAction.Demand, _
  Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class
 CollectionPropertyControl
  Inherits Control
  Private _header As String
  Private _employees As New
 ArrayList()
  
  
  Public Property Header() As
 String
     Get
        Return _header
     End Get
     Set
        _header = value
     End Set
  End Property
  
  
  
  
  Public ReadOnly Property
 Employees() As ArrayList
     Get
        Return _employees
     End Get
  End Property
  
  ' Override the CreateChildControls method to 
  ' add child controls to the Employees property when this
  ' custom control is requested from a page.
  Protected Overrides Sub
 CreateChildControls()
     Dim label As New Label()
     label.Text = Header
     label.BackColor = Color.Beige
     label.ForeColor = Color.Red
     Controls.Add(label)
     Controls.Add(New LiteralControl("<BR>
 <BR>"))
     
     Dim table As New Table()
     Dim htr As New TableRow()
     
     Dim hcell1 As New TableHeaderCell()
     hcell1.Text = "Name"
     htr.Cells.Add(hcell1)
     
     Dim hcell2 As New TableHeaderCell()
     hcell2.Text = "Title"
     htr.Cells.Add(hcell2)
     
     Dim hcell3 As New TableHeaderCell()
     hcell3.Text = "Alias"
     htr.Cells.Add(hcell3)
     table.Rows.Add(htr)
     
     table.BorderWidth = Unit.Pixel(2)
     table.BackColor = Color.Beige
     table.ForeColor = Color.Red
     Dim employee As Employee
     For Each employee In
  Employees
        Dim tr As New TableRow()
        
        Dim cell1 As New
 TableCell()
        cell1.Text = employee.Name
        tr.Cells.Add(cell1)
        
        Dim cell2 As New
 TableCell()
        cell2.Text = employee.Title
        tr.Cells.Add(cell2)
        
        Dim cell3 As New
 TableCell()
        cell3.Text = employee.Alias
        tr.Cells.Add(cell3)
        
        table.Rows.Add(tr)
     Next employee
     Controls.Add(table)
  End Sub 'CreateChildControls
 
End Class 'CollectionPropertyControl
// Use the PersistChildren attribute to set the Persist
// property to false so that none of this class's
// child controls will be persisted as controls. They will
// be persisted only as child elements of this class.
// If you set the PersistChildren attribute to true, or if you
// do not include this attribute when you create a control,
// the child controls will be persisted as controls.   
[PersistChildren(false)]
[AspNetHostingPermission(SecurityAction.Demand, 
   Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class CollectionPropertyControl
 : Control
{  
   private String header;
   private ArrayList employees = new ArrayList();
   
   public String Header
   {
      get
      {
         return header;
      }
      set
      {
         header = value;
      }
   }


   
   public ArrayList Employees
   {
      get 
      {
         return employees;
      }
   }
   // Override the CreateChildControls method to 
   // add child controls to the Employees property when this
   // custom control is requested from a page.
   protected override void CreateChildControls()
   {
      Label label = new Label();
      label.Text = Header;
      label.BackColor = Color.Beige;
      label.ForeColor = Color.Red;
      Controls.Add(label);
      Controls.Add(new LiteralControl("<BR> <BR>"));

      Table table = new Table();
      TableRow htr = new TableRow();

      TableHeaderCell hcell1 = new TableHeaderCell();    
      hcell1.Text = "Name";
      htr.Cells.Add(hcell1);

      TableHeaderCell hcell2 = new TableHeaderCell();
      hcell2.Text = "Title";
      htr.Cells.Add(hcell2);
      
      TableHeaderCell hcell3 = new TableHeaderCell();
      hcell3.Text = "Alias";
      htr.Cells.Add(hcell3);
      table.Rows.Add(htr);

      table.BorderWidth = 2;
      table.BackColor = Color.Beige;
      table.ForeColor = Color.Red;
      foreach (Employee employee in Employees)
      {
         TableRow tr = new TableRow();

         TableCell cell1 = new TableCell();
         cell1.Text = employee.Name;
         tr.Cells.Add(cell1);
         
         TableCell cell2 = new TableCell();
         cell2.Text = employee.Title;
         tr.Cells.Add(cell2);
         
         TableCell cell3 = new TableCell();
         cell3.Text = employee.Alias;
         tr.Cells.Add(cell3);
         
         table.Rows.Add(tr);
      }
      Controls.Add(table);
      
   }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

PersistChildrenAttribute コンストラクタ (Boolean, Boolean)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

2 つブール値を使用して PersistChildrenAttribute クラス新しインスタンス初期化します。1 つ目のブール値は、入れ子になった内容入れ子になったコントロールとして保持するかどうか示し2 つ目のブール値は、カスタム保持方法使用するかどうか示します

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Sub New ( _
    persist As Boolean, _
    usesCustomPersistence As Boolean _
)
Dim persist As Boolean
Dim usesCustomPersistence As Boolean

Dim instance As New PersistChildrenAttribute(persist,
 usesCustomPersistence)
public PersistChildrenAttribute (
    bool persist,
    bool usesCustomPersistence
)
public:
PersistChildrenAttribute (
    bool persist, 
    bool usesCustomPersistence
)
public PersistChildrenAttribute (
    boolean persist, 
    boolean usesCustomPersistence
)
public function PersistChildrenAttribute (
    persist : boolean, 
    usesCustomPersistence : boolean
)

パラメータ

persist

入れ子になった内容入れ子になったコントロールとして保持する場合trueそれ以外場合false

usesCustomPersistence

カスタマイズした方法保持する場合trueそれ以外場合false

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
PersistChildrenAttribute クラス
PersistChildrenAttribute メンバ
System.Web.UI 名前空間

PersistChildrenAttribute コンストラクタ




英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「PersistChildrenAttribute コンストラクタ」の関連用語

PersistChildrenAttribute コンストラクタのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



PersistChildrenAttribute コンストラクタのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS