locked
Viewstate Via Server.Redirect not working why? RRS feed

  • Question

  • User604230926 posted

    I have a label and button on my first page and the following event handler for button click:

                ViewState["Name"] = TextBox1.Text;
                Server.Transfer("WebForm2.aspx");

    and I have the following code for formload evant of my the other page(Page2):

    protected void Page_Load(object sender, EventArgs e)
            {
                Label1.Text = "Name is:" +ViewState["Name"];
            }

    But it is not working, why? 

    PS:I know I can use "Postbackurl" property to have crosspage to solve the problem. Also I knwo I cna use session or application to solve the problem. But why ViewState is not working with "Server.Redirect" whcih redirects you to another page on THE SAME SERVER AND VARIABLES SHOULD BE VISIABLE AND ACCESSIBLE!

    Thanks



    Monday, October 15, 2012 3:23 AM

Answers

All replies