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




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com