Problem with LoadViewState

I

IgorW

Hallo NG,

I have problem with the methode LoadViewState.
I develop a custom DataBound control, which create other DataBound
Controls.
That is the TabStrip and TabStripRow. The TabStripRow create the
TabStripRowItem.
After PostBack the method LoadViewState in TabStrip was called but not in
TabStripRow.
Have anybody a idea why the method LoadViewState in TabStripRow are not
called?
The SaveViewState works without problems.

Thanks

Igor
 
J

John Saunders

IgorW said:
Hallo NG,

I have problem with the methode LoadViewState.
I develop a custom DataBound control, which create other DataBound
Controls.
That is the TabStrip and TabStripRow. The TabStripRow create the
TabStripRowItem.
After PostBack the method LoadViewState in TabStrip was called but not in
TabStripRow.
Have anybody a idea why the method LoadViewState in TabStripRow are not
called?
The SaveViewState works without problems.

Did TabStrip ever create its child controls?
 
I

Igor

yes, at databinding with datavalues, at postback should that read the values
from ViewState.
 
J

John Saunders

Igor said:
yes, at databinding with datavalues, at postback should that read the values
from ViewState.

Ok, but you need to store in ViewState everything necessary to recreate the
controls as they were at the end of the last postback. This not only
includes the ViewState of all the child controls, it also includes
everything you need to create the child controls. For instance, if you
created a number of tabs based on the data you were bound to, then you will
need to store the number of tabs in ViewState. On PostBack, you'll read the
number of tabs and create that many tabs and add them to the Controls
collection of the TabStrip. The individual tabs will read their own
ViewState, but you will have to create them first!
 
I

IgorW

yes, I du it exactly the same, as they say.
TabStrip overrides method SaveViewState and LoadViewState.

<
Protected Overrides Function SaveViewState() As Object
Dim NewState As New ArrayList
With NewState
.Add(MyBase.SaveViewState())
.Add(m_RowCount)
End With
Return NewState
End Function

Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim OldState As ArrayList = CType(savedState, ArrayList)
MyBase.LoadViewState(OldState.Item(0))
m_RowCount = OldState.Item(1)
End Sub
and the TabStipRow Overrides this methods
<
Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim OldState As ArrayList = CType(savedState, ArrayList)
MyBase.LoadViewState(OldState.Item(0))
m_RowItemsCount = OldState.Item(1)
End Sub
Protected Overrides Function SaveViewState() As Object
Dim NewState As New ArrayList
With NewState
.Add(MyBase.SaveViewState)
.Add(m_RowItemsCount)
End With
Return NewState
End FunctionAt First call are the SaveViewState() called as as usual and the
RowItemsCount are saved to ViewState.
but at PostBack is the Value <this(or in VB "Me").ViewState[1]> =
"null"(in VB "Nothing") and the void LoadViewState are not called.
Do you know, what is important for ViewState?

Thanks,

Igor


Am Fri, 10 Oct 2003 21:58:23 -0400 hat John Saunders <john.saunders at
surfcontrol.com> geschrieben:
 
J

John Saunders

IgorW said:
yes, I du it exactly the same, as they say.
TabStrip overrides method SaveViewState and LoadViewState.

<
Protected Overrides Function SaveViewState() As Object
Dim NewState As New ArrayList
With NewState
.Add(MyBase.SaveViewState())
.Add(m_RowCount)
End With
Return NewState
End Function

Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim OldState As ArrayList = CType(savedState, ArrayList)
MyBase.LoadViewState(OldState.Item(0))
m_RowCount = OldState.Item(1)
End Sub
and the TabStipRow Overrides this methods
<
Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim OldState As ArrayList = CType(savedState, ArrayList)
MyBase.LoadViewState(OldState.Item(0))
m_RowItemsCount = OldState.Item(1)
End Sub
Protected Overrides Function SaveViewState() As Object
Dim NewState As New ArrayList
With NewState
.Add(MyBase.SaveViewState)
.Add(m_RowItemsCount)
End With
Return NewState
End FunctionAt First call are the SaveViewState() called as as usual and the
RowItemsCount are saved to ViewState.
but at PostBack is the Value <this(or in VB "Me").ViewState[1]> =
"null"(in VB "Nothing") and the void LoadViewState are not called.
Do you know, what is important for ViewState?

I've never used an ArrayList to store view state. Try using an array of
objects instead:

Dim NewState As New Object(2)
NewState(0) = MyBase.SaveViewState()
NewState(1) = m_RowItemsCount
 
I

IgorW

Ok, I try it out.
But I have a control, that used the ArrayList for ViewState - it works.
in the Wrox book "Professional ASP.Net Server Controls (Programmer to
Programmer)" are written that the ArrayList are provided type for
ViewState.

salute

Igor

Am Sun, 12 Oct 2003 09:50:21 -0400 hat John Saunders <john.saunders at
surfcontrol.com> geschrieben:
IgorW said:
yes, I du it exactly the same, as they say.
TabStrip overrides method SaveViewState and LoadViewState.

<
Protected Overrides Function SaveViewState() As Object
Dim NewState As New ArrayList
With NewState
.Add(MyBase.SaveViewState())
.Add(m_RowCount)
End With
Return NewState
End Function

Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim OldState As ArrayList = CType(savedState, ArrayList)
MyBase.LoadViewState(OldState.Item(0))
m_RowCount = OldState.Item(1)
End Sub
and the TabStipRow Overrides this methods
<
Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim OldState As ArrayList = CType(savedState, ArrayList)
MyBase.LoadViewState(OldState.Item(0))
m_RowItemsCount = OldState.Item(1)
End Sub
Protected Overrides Function SaveViewState() As Object
Dim NewState As New ArrayList
With NewState
.Add(MyBase.SaveViewState)
.Add(m_RowItemsCount)
End With
Return NewState
End FunctionAt First call are the SaveViewState() called as as usual and the
RowItemsCount are saved to ViewState.
but at PostBack is the Value <this(or in VB "Me").ViewState[1]> =
"null"(in VB "Nothing") and the void LoadViewState are not called.
Do you know, what is important for ViewState?

I've never used an ArrayList to store view state. Try using an array of
objects instead:

Dim NewState As New Object(2)
NewState(0) = MyBase.SaveViewState()
NewState(1) = m_RowItemsCount
 
I

IgorW

Hi,
I tried it with object array, but that don't helps.
any other idea?

salute

Igor

Ok, I try it out.
But I have a control, that used the ArrayList for ViewState - it works.
in the Wrox book "Professional ASP.Net Server Controls (Programmer to
Programmer)" are written that the ArrayList are provided type for
ViewState.

salute

Igor

Am Sun, 12 Oct 2003 09:50:21 -0400 hat John Saunders <john.saunders at
surfcontrol.com> geschrieben:
IgorW said:
yes, I du it exactly the same, as they say.
TabStrip overrides method SaveViewState and LoadViewState.

<
Protected Overrides Function SaveViewState() As Object
Dim NewState As New ArrayList
With NewState
.Add(MyBase.SaveViewState())
.Add(m_RowCount)
End With
Return NewState
End Function

Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim OldState As ArrayList = CType(savedState, ArrayList)
MyBase.LoadViewState(OldState.Item(0))
m_RowCount = OldState.Item(1)
End Sub


and the TabStipRow Overrides this methods
<
Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim OldState As ArrayList = CType(savedState, ArrayList)
MyBase.LoadViewState(OldState.Item(0))
m_RowItemsCount = OldState.Item(1)
End Sub
Protected Overrides Function SaveViewState() As Object
Dim NewState As New ArrayList
With NewState
.Add(MyBase.SaveViewState)
.Add(m_RowItemsCount)
End With
Return NewState
End Function

At First call are the SaveViewState() called as as usual and the
RowItemsCount are saved to ViewState.
but at PostBack is the Value <this(or in VB "Me").ViewState[1]> =
"null"(in VB "Nothing") and the void LoadViewState are not called.
Do you know, what is important for ViewState?

I've never used an ArrayList to store view state. Try using an array of
objects instead:

Dim NewState As New Object(2)
NewState(0) = MyBase.SaveViewState()
NewState(1) = m_RowItemsCount
 
J

John Saunders

IgorW said:
Hi,
I tried it with object array, but that don't helps.
any other idea?

My only idea is to try just putting m_RowCount directly into ViewState like
"ViewState("RowCount") = m_RowCount".
--
John Saunders
Internet Engineer
(e-mail address removed)


Ok, I try it out.
But I have a control, that used the ArrayList for ViewState - it works.
in the Wrox book "Professional ASP.Net Server Controls (Programmer to
Programmer)" are written that the ArrayList are provided type for
ViewState.

salute

Igor

Am Sun, 12 Oct 2003 09:50:21 -0400 hat John Saunders <john.saunders at
surfcontrol.com> geschrieben:
yes, I du it exactly the same, as they say.
TabStrip overrides method SaveViewState and LoadViewState.

<
Protected Overrides Function SaveViewState() As Object
Dim NewState As New ArrayList
With NewState
.Add(MyBase.SaveViewState())
.Add(m_RowCount)
End With
Return NewState
End Function

Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim OldState As ArrayList = CType(savedState, ArrayList)
MyBase.LoadViewState(OldState.Item(0))
m_RowCount = OldState.Item(1)
End Sub


and the TabStipRow Overrides this methods
<
Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim OldState As ArrayList = CType(savedState, ArrayList)
MyBase.LoadViewState(OldState.Item(0))
m_RowItemsCount = OldState.Item(1)
End Sub
Protected Overrides Function SaveViewState() As Object
Dim NewState As New ArrayList
With NewState
.Add(MyBase.SaveViewState)
.Add(m_RowItemsCount)
End With
Return NewState
End Function

At First call are the SaveViewState() called as as usual and the
RowItemsCount are saved to ViewState.
but at PostBack is the Value <this(or in VB "Me").ViewState[1]> =
"null"(in VB "Nothing") and the void LoadViewState are not called.
Do you know, what is important for ViewState?

I've never used an ArrayList to store view state. Try using an array of
objects instead:

Dim NewState As New Object(2)
NewState(0) = MyBase.SaveViewState()
NewState(1) = m_RowItemsCount
 
I

IgorW

I tried it already.
meanwhile, I found out, that if I create the TabStrip without use of
VS.NET designer - thus by hand:
Instantiate the TabStrip in Page_Init method and set the DataSource. so I
get the call of LoadViewState in TabStripRow and TabSripRowItem.
And here occurs the next problem: If I add the TabStrip by hand, how can I
control the position of it, if other controls are created with designer? I
mean - not the CSS, but Index in the Controls collection. If I use the
Method AddAt(index, control), I lost the control tree, with all the
consequences following from it.

oh,... my English [;-((
sorry

Am Mon, 13 Oct 2003 08:40:35 -0400 hat John Saunders <john.saunders at
surfcontrol.com> geschrieben:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top