PageStatePersister.ControlState 속성

정의

현재 Page 개체에 포함된 컨트롤에서 웹 서버에 대한 HTTP 요청 간에 유지하기 위해 사용하는 데이터를 나타내는 개체를 가져오거나 설정합니다.

public:
 property System::Object ^ ControlState { System::Object ^ get(); void set(System::Object ^ value); };
public object ControlState { get; set; }
member this.ControlState : obj with get, set
Public Property ControlState As Object

속성 값

뷰 상태 데이터가 들어 있는 개체입니다.

예제

다음 코드 예제는 클래스에서 파생 되는 방법을 보여 줍니다.는 PageStatePersister 초기화 클래스는 ControlState 속성입니다. 이 예제에서는 합니다 ControlState 속성에 할당 된를 Second 필드를 Pair 개체를 사용 하 여 serialize를 ObjectStateFormatter 클래스입니다. 경우는 Load 메서드를 호출 합니다 ObjectStateFormatter 클래스 뷰 상태 및 컨트롤 상태 정보를 역직렬화하는 데 사용 됩니다 및 ControlState 속성은 결과에서 초기화 됩니다 Pair 개체의 Second 필드입니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 PageStatePersister 클래스입니다.

//
// Load ViewState and ControlState.
//
public override void Load()
{
    Stream stateStream = GetSecureStream();

    // Read the state string, using the StateFormatter.
    StreamReader reader = new StreamReader(stateStream);

    IStateFormatter formatter = this.StateFormatter;
    string fileContents = reader.ReadToEnd();

    // Deserilize returns the Pair object that is serialized in
    // the Save method.
    Pair statePair = (Pair)formatter.Deserialize(fileContents);

    ViewState = statePair.First;
    ControlState = statePair.Second;
    reader.Close();
    stateStream.Close();
}
'
' Load ViewState and ControlState.
'
Public Overrides Sub Load()

    Dim stateStream As Stream
    stateStream = GetSecureStream()

    ' Read the state string, using the StateFormatter.
    Dim reader As New StreamReader(stateStream)

    Dim serializedStatePair As String
    serializedStatePair = reader.ReadToEnd
    Dim statePair As Pair

    Dim formatter As IStateFormatter
    formatter = Me.StateFormatter

    ' Deserilize returns the Pair object that is serialized in
    ' the Save method.      
    statePair = CType(formatter.Deserialize(serializedStatePair), Pair)

    ViewState = statePair.First
    ControlState = statePair.Second
    reader.Close()
    stateStream.Close()
End Sub

설명

컨트롤 상태는 중요 한 보기 상태 데이터를 웹 서버 컨트롤 필요가 함수 및 기본 보기 상태 정보를 별도 개체에 포함 된 구성 개체입니다. 컨트롤 상태 데이터의 뷰 상태를 비활성화 하는 경우 영향을 받지 않습니다는 Page 수준 수 있지만 사용 하도록 추가로 구현 단계가 필요 합니다. 사용 하 여 대 한 자세한 내용은 합니다 ViewState 속성 및 컨트롤 상태 컨트롤을 개발할 때 참조 사용자 지정 ASP.NET 서버 컨트롤 개발합니다.

적용 대상