Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8891009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:37:51+00:00 2026-06-14T22:37:51+00:00

I have a multiview and have 2 views inside it. I am going to

  • 0

I have a multiview and have 2 views inside it. I am going to paste a sample code.

<asp:MultiView ID="MultiView1" ActiveViewIndex="0" runat="server">
<asp:View ID="View1" runat="server">
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" Text="view1" />
    <asp:Label ID="Label2" runat="server" ></asp:Label>
</asp:View>
<asp:View ID="View2" runat="server">
    <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
    <asp:Button ID="Button2" runat="server" Text="view2" />
</asp:View>
</asp:MultiView>

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

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

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.

Why there is no value in viewstate?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:37:53+00:00Added an answer on June 14, 2026 at 10:37 pm

    Asp.Net viewstate is very different from normal get/post browser requests in other systems such as Rails, PHP, or even Asp.Net MVC.

    Here is what is going on in your scenario:

    1. User’s browser does HTTP get on page for first time. This is not a postback.
    2. User fills in TextBox1 and clicks Button1. This is a postback (HTTP post).
    3. On the server, the information in the encrypted hidden __VIEWSTATE variable is unpacked and compared with the new values for TextBox1 and Button1 according to the post data in the request.
    4. Asp.Net identifies state changes and fires events in your server code. This results in the change of the active view index to 1.
    5. The browser now receives the page with View2 shown.
    6. User hits Button2. This is a postback (HTTP post).
    7. The server goes through the same process as before comparing viewstate to post data and fires the Button2 click event.
    8. Your code now does something different. When you do a Response.Redirect, the server does not send back the page with new viewstate. You are sending a short header without the preserved viewstate information in the hidden form variable. The redirect forces the browser to immediately do an HTTP get operation to the url specified. THIS IS NOT A POSTBACK and the view state has been lost. It is exactly the same scenario as the first HTTP get from the user’s browser in step 1.

    I hope this helps. I think it is safe to admit that Microsoft has recognized the drawbacks from their viewstate model in Asp.net. It makes it quite difficult to implement sexy, modern ajax applications where the browser is maintaining most of the application state and just wants to make small requests for new data from the server. I think this is one of the primary motivations for abandoning the viewstate model in Asp.Net MVC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following structure <asp:UpdatePanel ID=MyUpdatePanel runat=server> <ContentTemplate> <asp:MultiView ID=MyViews runat=server> <asp:View ID=List
I have the following multiview set up in my aspx page: <asp:MultiView id=MultiView1 runat=server
I have this code which adds a x number of views to a Multiview
I'm working on a multiview app for iPhone and currently have my views (VIEW)
I have a MultiView with several Views within it. When the ActiveView changes I
I have a multiview application using a tab bar to switch views. One is
I have a .net page with a multiview control. In the first view I
I have a multi view app, to swap views I use: -(IBAction) goSecond{ [self
I have question here, i design multiview application using view base template. Page 1
I have a div inside a MultiView that is inside an UpdatePanel. When I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.