ViewState problem

bri189a

Senior Contributor
Joined
Sep 11, 2003
Messages
1,004
Location
VA
I have a Page that I have a property set up on that I want to be able to access from children controls:

On User Control:

((Index)this.Parent.NamingContainer).TestProperty = 1;

On the Page:

public int TestProperty
{

get
{
if(ViewState["Test"]==null)
ViewState["Test"] = 1;
return ViewState["Test"];
}
set
{
ViewState["Test"] = value;
}

}

Problem is that even though my child control will set the parent page property correctly, when the page is reloaded the ViewState is null again...why (I have ViewState enabled)? I thought it was suppose to propagate...I'm using Session as a replacement for now and it works fine.
 
Back
Top