title: passing values using viewstate across postback in multiview
body: <p>I have a multiview and have 2 views inside it. I am going to paste a sample code. </p>
  
  <pre><code>&lt;asp:MultiView ID="MultiView1" ActiveViewIndex="0" runat="server"&gt;
  &lt;asp:View ID="View1" runat="server"&gt;
      &lt;asp:TextBox ID="TextBox1" runat="server"&gt;&lt;/asp:TextBox&gt;
      &lt;asp:Button ID="Button1" runat="server" Text="view1" /&gt;
      &lt;asp:Label ID="Label2" runat="server" &gt;&lt;/asp:Label&gt;
  &lt;/asp:View&gt;
  &lt;asp:View ID="View2" runat="server"&gt;
      &lt;asp:TextBox ID="TextBox3" runat="server"&gt;&lt;/asp:TextBox&gt;
      &lt;asp:Button ID="Button2" runat="server" Text="view2" /&gt;
  &lt;/asp:View&gt;
  &lt;/asp:MultiView&gt;
  </code></pre>
  
  <p>I want the value in txtbox1 to be there in postback. Though multiviews maintain state i do response.redirect to pass querystring to view2. Since i do postback i cannot use the value in txtbox1(in view1), in view2. The value in txtbox1 becomes null during postback. I tried the following code</p>
  
  <pre><code>Public Partial Class viewstatetest
  Inherits System.Web.UI.Page
  
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles    Me.Load
  If (Not Page.IsPostBack()) Then
      MultiView1.ActiveViewIndex = 0
  Else
      TypedPassword = TextBox1.Text
      TextBox1.Attributes.Add("value", TypedPassword)
  End If
  End Sub
  
  Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles   Button1.Click
  MultiView1.ActiveViewIndex = 1
  End Sub
  
  Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles    Button2.Click
  MultiView1.ActiveViewIndex = 0
  Label1.Text = TextBox1.Text
  Response.Redirect("viewstatetest.aspx")
  End Sub
  
  Public Property TypedPassword() As String
  Get
      If (ViewState("TypedPassword") IsNot Nothing) Then
          Return CStr(ViewState("TypedPassword"))
      End If
      Return ""
  End Get
  Set(ByVal value As String)
       ViewState("TypedPassword") = value
  End Set
  End Property
  End Class
  </code></pre>
  
  <p>When the page loads for the first time, i type something in txtbox1 in view1 and click on the button, view2 is loaded and i have a code that gets the value of the txtbox1 and writes the value inlabel1 in view1. And when i do response.redirect the textbox1 becomes null and view also become null.</p>
  
  <p>Why there is no value in viewstate?</p>
  
  <p>Thanks!</p>