F
foldface
Hi
I have the problem at the moment that I have to build
a page with all its dynamic buttons etc in order to get
postbacks on those buttons, then rebuild the control tree
in response to any possible postback.
What if I just stored the complete Control tree structure in
the session? Alternatively any better ways of doing this?
I have tried it on a simple page with 4 buttons and it
worked fine, e.g. something like this:
if(!IsPostBack)
{
for(int i=0; i<4; i++)
{
Button button = new Button();
button.Text = "Keep Me: " + i.ToString();
button.Click += new EventHandler(button_Click);
this.ph.Controls.Add(button);
}
this.Session["everything"] = this.ph;
}
else
{
PlaceHolder oldOne = (PlaceHolder)(Session["everything"]);
ControlCollection coll = (ControlCollection)oldOne.Controls;
while(coll.Count>0)
{
this.ph.Controls.Add(coll[0]);
}
this.Session["everything"] = this.ph;
}
Any views?
Ta
Shard
I have the problem at the moment that I have to build
a page with all its dynamic buttons etc in order to get
postbacks on those buttons, then rebuild the control tree
in response to any possible postback.
What if I just stored the complete Control tree structure in
the session? Alternatively any better ways of doing this?
I have tried it on a simple page with 4 buttons and it
worked fine, e.g. something like this:
if(!IsPostBack)
{
for(int i=0; i<4; i++)
{
Button button = new Button();
button.Text = "Keep Me: " + i.ToString();
button.Click += new EventHandler(button_Click);
this.ph.Controls.Add(button);
}
this.Session["everything"] = this.ph;
}
else
{
PlaceHolder oldOne = (PlaceHolder)(Session["everything"]);
ControlCollection coll = (ControlCollection)oldOne.Controls;
while(coll.Count>0)
{
this.ph.Controls.Add(coll[0]);
}
this.Session["everything"] = this.ph;
}
Any views?
Ta
Shard