I'm using two web controls. Web control A includes webcontrol B. When webcontrol A is called, it automatically calls webcontrolB. WebcontrolB passes a value to the method Modify() of webcontrolA. I would like to store an object, and I do it using viewstate:
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
object o = Object;
ViewState["o"] = o;
}
}
The problem is that when I return back to webcontrolA the object that I retrieve from ViewState is null. So the object is not stored when another webcontrol is executed. Ho can I store it?? I tried also Session but it gaves me the following error: "Error Message: Object reference not set to an instance of an object"
to retrieve the value from viewstate I used this:
public void Modify(int i)
{
object o = (object)ViewState["o"]; //result is null :(
}