Click here to Skip to main content
16,018,264 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
If View State value is "X" and I have changed it to "Y" in Page_Load then what will be the final value of View State?

thanks in advance
Posted

1 solution

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class About : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ViewState["xx"] = "x";
        if (!IsPostBack)
        {
            ViewState["xx"] = "y";
        }
        Response.Write(ViewState["xx"]);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

    }
}



in this case first page load return value 'y' ... and when u click the btn than it's return
'x' .....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900