J
Josema
Hi to all,
I have a webform.aspx and inside i have a dropdown list with autopostback
and a place holder...
Depending of the selected index that the user selects in the dropdownlist i
load a usercontrol into the place holder...
i dont know why im getting this error:
Failed to load viewstate. The control tree into which viewstate is being
loaded must match the control tree that was used to save viewstate during the
previous request. For example, when adding controls dynamically, the controls
added during a post-back must match the type and position of the controls
added during the initial request.
and this is that i have:
if(!Page.IsPostBack)
{
//fill the dropdownlist with the options
}
else
{
switch(this.OpcionInicialDDL1.SelectedValue)
{
case "0": //Option 0 is "choose option" dont fill the placeholder
break;
case "1": //Option 1 is "Phone", add to place holder the phone
usercontrol
PhoneControl=(UserControls.Phone)LoadControl("UserControls/Phone.ascx");
//load the control phone
this.OpcionPH.Controls.Add(PhoneControl);//add into the placeholder
controls the control phone
break;
case "2": //Option 2 is "Internet", add to place holder the Internet
usercontrol
InternetControl=(UserControls.Internet)LoadControl("UserControls/Internet.ascx"); //load the control internet
this.OpcionPH.Controls.Add(InternetControl); //add into the placeholder
control the internet
break;
case "3": //Option 3 is "Phone + Internet", add to place holderthe Phone
and Internet usercontrol
PhoneControl=(UserControls.Phone)LoadControl("UserControls/Phone.ascx");
//load the control phone
InternetControl=(UserControls.Internet)LoadControl("UserControls/Internet.ascx"); //load control internet
this.OpcionPH.Controls.Add(PhoneControl); //add into the place holder the
phone control
this.OpcionPH.Controls.Add(InternetControl); //add into the place holder
the internet control
break;
}
}
Any help would be appreciated.
I have a webform.aspx and inside i have a dropdown list with autopostback
and a place holder...
Depending of the selected index that the user selects in the dropdownlist i
load a usercontrol into the place holder...
i dont know why im getting this error:
Failed to load viewstate. The control tree into which viewstate is being
loaded must match the control tree that was used to save viewstate during the
previous request. For example, when adding controls dynamically, the controls
added during a post-back must match the type and position of the controls
added during the initial request.
and this is that i have:
if(!Page.IsPostBack)
{
//fill the dropdownlist with the options
}
else
{
switch(this.OpcionInicialDDL1.SelectedValue)
{
case "0": //Option 0 is "choose option" dont fill the placeholder
break;
case "1": //Option 1 is "Phone", add to place holder the phone
usercontrol
PhoneControl=(UserControls.Phone)LoadControl("UserControls/Phone.ascx");
//load the control phone
this.OpcionPH.Controls.Add(PhoneControl);//add into the placeholder
controls the control phone
break;
case "2": //Option 2 is "Internet", add to place holder the Internet
usercontrol
InternetControl=(UserControls.Internet)LoadControl("UserControls/Internet.ascx"); //load the control internet
this.OpcionPH.Controls.Add(InternetControl); //add into the placeholder
control the internet
break;
case "3": //Option 3 is "Phone + Internet", add to place holderthe Phone
and Internet usercontrol
PhoneControl=(UserControls.Phone)LoadControl("UserControls/Phone.ascx");
//load the control phone
InternetControl=(UserControls.Internet)LoadControl("UserControls/Internet.ascx"); //load control internet
this.OpcionPH.Controls.Add(PhoneControl); //add into the place holder the
phone control
this.OpcionPH.Controls.Add(InternetControl); //add into the place holder
the internet control
break;
}
}
Any help would be appreciated.