title: Keep state of multiple usercontrols in ASP.NET
body: <p>I am generating instances of a <code>UserControl</code> and putting them in an <code>UL</code>. In my <code>UserControl</code> there is a button with an event. I want to ask how I can keep the state of the UserControls I generated so that they remain on the page after a postback and also to catch their events.</p>
  
  <pre><code>For i As Integer = 0 To lstFoo.Count - 1     
    Dim liFoo As New HtmlGenericControl("li")
    Dim ucMyFoo As ucFoo = LoadControl("userControls/ucFoo.ascx")
  
    liFoo.Controls.Add(ucMyFoo)   
    ucMyFoo.DoSomething()
    ulFoo.Controls.Add(liFoo)
  Next
  </code></pre>