StateBag.Keys 속성

정의

StateBag 개체의 항목을 나타내는 키 컬렉션을 가져옵니다.

public:
 property System::Collections::ICollection ^ Keys { System::Collections::ICollection ^ get(); };
public System.Collections.ICollection Keys { get; }
member this.Keys : System.Collections.ICollection
Public ReadOnly Property Keys As ICollection

속성 값

ICollection

키 컬렉션입니다.

구현

예제

다음 코드 예제는 Keys 속성입니다.

private string GetMruList(string selectedValue) {
   StateBag state = ViewState;
   if (state.Count > 0) {
      int upperBound = state.Count;
      string[] keys = new string[upperBound];
      StateItem[] values = new StateItem[upperBound];
      state.Keys.CopyTo(keys, 0);
      state.Values.CopyTo(values, 0);
      StringBuilder options = new StringBuilder();
      for(int i = 0; i < upperBound; i++) {
         options.AppendFormat("<option {0} value={1}>{2}", (selectedValue == keys[i])?"selected":"", keys[i], values[i].Value);
      }
      return options.ToString();
   }
   return "";
}
Private Function GetMruList(selectedValue As String) As String
   Dim state As StateBag = ViewState
   If state.Count > 0 Then
      Dim upperBound As Integer = state.Count
      Dim keys(upperBound) As String
      Dim values(upperBound) As StateItem
      state.Keys.CopyTo(keys, 0)
      state.Values.CopyTo(values, 0)
      Dim options As New StringBuilder()
      Dim i As Integer
      For i = 0 To upperBound - 1
         options.AppendFormat("<option {0} value={1}>{2}",IIf(selectedValue = keys(i), "selected", ""), keys(i), values(i).Value) 
      Next i
      Return options.ToString()
   End If
   Return ""
End Function 'GetMruList

설명

이러한 키는 컨트롤 속성의 이름입니다. 예를 들어 사용자 지정한 BGColor 컨트롤에 Table 속성을 만든 경우 컨트롤의 해당 속성을 나타내는 항목이 이 컬렉션에 Table 만들어 BGColor 집니다.

이러한 키는 현재 페이지 또는 서버 컨트롤의 StateBag 컬렉션에 저장된 개체의 StateItem 이름에 해당합니다.

메서드를 사용하여 이 컬렉션을 반복할 StateBag.GetEnumerator 수 있습니다.

적용 대상

추가 정보