.NETGURU
Saving/serializing treeView control into ViewState
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngwebcontrols' list.


Emmely
-- Moved from [aspngfreeforall] to [aspngwebcontrols] by Tony Stark <Click here to reveal e-mail address> --

-- Moved from [aspngdatagridrepeaterdatalist] to [aspngfreeforall] by Tony Stark <Click here to reveal e-mail address> --

Hi,

I have created a user control (ascx) which has a 'treeview' control inside
of it and I want to save the state of this treeview into ViewState.

Some background information: This control is embedded in an aspx file which
has a table set up so that different pages can be loaded into a different
cell depending on which node the user clicked in the tree (eg. Menu
navigation on left side of screen, page loaded in middle of screen)

The initial problem I experienced was that the entire menu collapsed when a
page is being loaded into the middle of the screen. Hence we needed to save
the treeview's state into ViewState so that when a page is loaded the
treeview menu remembered its own state and did not collapse.

I then tried the following code to attempt to save it into viewState (where
TreeView1 = Microsoft.Web.UI.WebControls.TreeView):

Protected Overrides Function SaveViewState() As Object

Viewstate("TreeView1") = Me.TreeView1

Return MyBase.SaveViewState()

End Function

However, this error then appeared:

"Type 'Microsoft.Web.UI.WebControls.TreeView' must be marked as Serializable
or have a TypeConverter other than ReferenceConverter to be put in
viewstate."

I then added the <Serializable()> _ attribute to my class but this did not
make a difference, and you also cannot inherit TypeConverter as a user
control already inherits System.Web.UI.UserControl by defaut.

If anyone has any suggestions in how I maintain the state of my treeView
control it would be much appreciated J

Thanks,

Emmely

Reply to this message...
 
    
Emmely
-- Moved from [aspngcache] to [aspngwebcontrols] by Tony Stark <Click here to reveal e-mail address> --

Hi,

I have created a user control (ascx) which has a 'treeview' control inside
of it and I want to save the state of this treeview into ViewState.

Some background information: This control is embedded in an aspx file which
has a table set up so that different pages can be loaded into a different
cell depending on which node the user clicked in the tree (eg. Menu
navigation on left side of screen, page loaded in middle of screen)

The initial problem I experienced was that the entire menu collapsed when a
page is being loaded into the middle of the screen. Hence we needed to save
the treeview's state into ViewState so that when a page is loaded the
treeview menu remembered its own state and did not collapse.

I then tried the following code to attempt to save it into viewState (where
TreeView1 = Microsoft.Web.UI.WebControls.TreeView):

Protected Overrides Function SaveViewState() As Object

Viewstate("TreeView1") = Me.TreeView1

Return MyBase.SaveViewState()

End Function

However, this error then appeared:

"Type 'Microsoft.Web.UI.WebControls.TreeView' must be marked as Serializable
or have a TypeConverter other than ReferenceConverter to be put in
viewstate."

I then added the <Serializable()> _ attribute to my class but this did not
make a difference, and you also cannot inherit TypeConverter as a user
control already inherits System.Web.UI.UserControl by defaut.

If anyone has any suggestions in how I maintain the state of my treeView
control it would be much appreciated J

Thanks,

Emmely

Reply to this message...
 
 
System.ComponentModel.ReferenceConverter
System.ComponentModel.TypeConverter
System.Web.UI.UserControl




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification