To elaborate, I have handled this by overriding the rendering of the page. It works fine for all combinations but from aFindJob(fj) to aNewJob(nj). Hence I can go from nj to fj, fj to aAddEmp(ae) to fj,ae to nj, nj to ae, and fails only on fj to nj. It throws a failed to load view state error. the code is as follows. I cant work out why it is doing it.
private void aFindJob_Click(object sender, System.EventArgs e)
{
ph1.Controls.Clear();
Bindph("FindProject.ascx");
}
private void aNewJob_Click(object sender, System.EventArgs e)
{
ph1.Controls.Clear();
Bindph("NewProject.ascx");
}
private void aAddEmp_Click(object sender, System.EventArgs e)
{
ph1.Controls.Clear();
Bindph("AddEmployee.ascx");
}
private void Bindph(string usrctl)
{
UserControl uc1 = (UserControl)LoadControl(usrctl);
this.ph1.Controls.Clear();
this.ph1.Controls.Add(uc1);
}
protected override void Render(HtmlTextWriter output)
{
if (IsPostBack && this.ph1.HasControls())
{
switch (World.GetPostBackControl(this).ID)
{
case "aNewJob":
ph1.Controls.Clear();
Bindph("NewProject.ascx");
break;
case "aFindJob":
ph1.Controls.Clear();
Bindph("FindProject.ascx");
break;
case "aAddEmp":
ph1.Controls.Clear();
Bindph("AddEmployee.ascx");
break;
default:
Bindph("NewProject.ascx");
break;
}
}
for (int i= 0;i<=Controls.Count -1;++i)
{
Controls[i].RenderControl(output);
}
}
thanks for any help.
Scott
|