Click here to Skip to main content
16,016,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected void Page_InitComplete(object sender, EventArgs e)
       {
           // Raised by the  Page object.
           //Use this event for processing tasks that require all initialization be complete.
           //till view state not loaded hence use this event to make changes to view state
           StateBag v = ViewState;
           v.Add("Text", "changed");
          //what is the use of adding this name and value
       }
Posted

1 solution

In Page_InitComplete, my understanding is that the ViewState is not actually there for you to manipulate. Rather than manipulate the ViewState like this, you would be better overriding the SaveViewState method like this:
C#
protected override object SaveViewState()
{
  object[] vs = new object[2];
  vs[0] = base.SaveViewState(); // This gets the original viewstate
  vs[1] = _somethingToSave;

  return vs;
}
 
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