title: I get an exception while using a ViewState
body: <p>I get this:</p>
  
  <blockquote>
    <p>System.Runtime.Serialization.SerializationException</p>
    
    <p>Type 'System.Web.UI.WebControls.Button' in Assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.</p>
    
    <p>Exception Details: System.Runtime.Serialization.SerializationException: Type 'System.Web.UI.WebControls.Button' in Assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.</p>
  </blockquote>
  
  <p>I get it when I try to save a List to a viewState and recover it in the  Page_PreInit event.</p>
  
  <p>I set the buttons and add them to a list that I later save to a viewState:</p>
  
  <pre><code>ViewState["Buttons"] = buttons;
  </code></pre>
  
  <p>Then I want to retrieve them and attach them back to their eventhandlers:</p>
  
  <pre><code>void Page_PreInit(object sender, EventArgs e)
  {
  
      List&lt;Button&gt; btn = (List&lt;Button&gt;)ViewState["Buttons"];
      if (btn!=null)
      {
          foreach (var item in btn)
          {
              item.Width = 20;
              item.Command += obtainTopicsPerPage_Click;
              item.CommandName = tPage.ToString();
              item.Text = tPage.ToString();
          }
      }
  }
  </code></pre>