E
et
I. 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.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Web.HttpException: 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.
Source Error:
Line 70: 'do we want to clear controls???
Line 71: me.ph.Controls.clear
Line 72: me.ph.Controls.Add(me.oCtrlDemo)
Line 73: End Sub
Line 74:
On my default page, I have a treeview and when the user clicks an item, it
selects a control to load into a placeholder. I get this error after a
couple of clicks around, what am I doing wrong, I am clearing the controls,
and I even tried loading only if not postback, then tried reloading every
time... This is my code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'if not ispostback then
me.ph.Controls.clear
DoTheLoad()
'end if
End Sub
Public Sub tvwMenu_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles tvwMenu1.SelectedIndexChanged
intSelectedMenu = e.newnode.tostring
me.ph.Controls.clear
DoTheLoad(intSelectedMenu)
End Sub
Private Sub DoTheLoad(Optional i as string = "")
select case i
Case "0.0"
me.oCtrlDemo = LoadControl("Controls\ctl1.ascx")
Case "0.2"
me.oCtrlDemo = LoadControl("ctl2.ascx")
Case else
me.oCtrlDemo = LoadControl("Controls\ctlDefault.ascx")
End Select
me.ph.Controls.clear
me.ph.Controls.Add(me.oCtrlDemo)
End Sub
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.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Web.HttpException: 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.
Source Error:
Line 70: 'do we want to clear controls???
Line 71: me.ph.Controls.clear
Line 72: me.ph.Controls.Add(me.oCtrlDemo)
Line 73: End Sub
Line 74:
On my default page, I have a treeview and when the user clicks an item, it
selects a control to load into a placeholder. I get this error after a
couple of clicks around, what am I doing wrong, I am clearing the controls,
and I even tried loading only if not postback, then tried reloading every
time... This is my code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'if not ispostback then
me.ph.Controls.clear
DoTheLoad()
'end if
End Sub
Public Sub tvwMenu_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles tvwMenu1.SelectedIndexChanged
intSelectedMenu = e.newnode.tostring
me.ph.Controls.clear
DoTheLoad(intSelectedMenu)
End Sub
Private Sub DoTheLoad(Optional i as string = "")
select case i
Case "0.0"
me.oCtrlDemo = LoadControl("Controls\ctl1.ascx")
Case "0.2"
me.oCtrlDemo = LoadControl("ctl2.ascx")
Case else
me.oCtrlDemo = LoadControl("Controls\ctlDefault.ascx")
End Select
me.ph.Controls.clear
me.ph.Controls.Add(me.oCtrlDemo)
End Sub