2009-03-13 14 views
0

コントロールのスタイルを設定するために使用できる多数のプロパティを持つコンポジットコントロールがあります。これらのプロパティをグループ化して、ViewStateのプロパティの一部を維持したい場合 コントロールのマークアップは次のようになります。

ViewStateに入れ子になったCompositeControlプロパティを格納する方法

<cc:Test id="test"> 
    <Toolbar Items="add,delete" Enabled="true" /> 
    <Grid Enabled="true" AllowSort="true" AllowFilter="true" /> 
</cc:Test> 

私のコードのようになります。この

<ParseChildren(true)> <PersistChildren(true)> _ 
Public Class Test Inherits CompositeControl 

    Private _grid As New GridStyle(); 
    <PersistenceMode(PersistenceMode.InnerProperty)> _ 
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _ 
    Public ReadOnly Property Grid As GridStyle 
     Get 
      Return _grid; 
     End Get 
    End Property 
End Class 

Public Class GridStyle 
    private _allowFilter As Boolean = False; 
    Public Property AllowFilter As Boolean 
     Get 
      Return _allowFilter 
     End Get 
     Set(value As Boolean) 
      _allowFilter = value 
     End Set 
    End Property 
End Class 


ViewStateのは、私はViewStateにAllowFilterプロパティの状態を維持するので、どのようにGridStyleクラスからアクセスできないのですか?

答えて

1
カスタムコントロールで

(またはカスタムコントロール内で使用される標準コントロールのラッパーを作る)あなたはこれがうまくMSDNに文書化し、一般

でウェブれるSaveViewStateとLoadViewState

をオーバーライドする必要があります

関連する問題