title: Viewstate does not persist after postback
body: <p>I'm having some problems in persisting the viewstate on postback for a Control (vb.net)</p>
  
  <p>here's some code i've put in my control:</p>
  
  <pre><code>Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
              MyBase.OnInit(e)
              Me.EnableViewState = True
              Me.ViewStateMode = System.Web.UI.ViewStateMode.Enabled
              If Not Page.IsPostBack Then
                  _SortTime = DateTime.Now
                  _SortTime.AddSeconds(-10) ' incase the fileserver and webserver date are out of sync
                  ViewState("PageLoadTimeStamp") = _SortTime      
              End If
          End Sub
  </code></pre>
  
  <p>onload:</p>
  
  <pre><code>Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
          MyBase.OnLoad(e)
  
          _SortTime = CType(ViewState("PageLoadTimeStamp"), DateTime)
  
  End Sub
  </code></pre>
  
  <p>But on every postback, the viewstate is empty again.</p>
  
  <p><strong>Update</strong>: What do i want to do?
  I want to store the time when the user first loads the page. Then, the user will do multiple postbacks. On every postback i need to know that time.</p>
  
  <p><strong>Update 2:</strong> Context:</p>
  
  <ul>
  <li>An aspx page (Editor.aspx) will load a web control (ObjectsEditor.ascx) dynamicly</li>
  <li>ObjectsEditor.ascx contains of a single custom control (Objects.vb)</li>
  <li>Objects.vb will create another custom control (ObjectsContainer.vb) and add it to it's controls
  It is the ObjectsContainer that needs to persist the viewstate.</li>
  </ul>
  
  <p>I'm setting EnableViewState = "true" everywhere i can, but still no result. Do i really need to set those properties here. (ViewStateMode and EnableViewState) If not, where should i handle this and what is the difference between those properties?</p>
  
  <p>Many thanks.</p>