This is a migrated thread and some comments may be shown as answers.

Cannot Save Dock State To Database/Prometheus

8 Answers 208 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Michael Onstad
Top achievements
Rank 1
Michael Onstad asked on 27 Jan 2008, 06:44 AM

Type 'Telerik.Web.UI.DockState' in Assembly 'Telerik.Web.UI, Version=2007.3.1314.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4' is not marked as serializable.

I need to serialiaze the List<DockState> so I can save the XML to the database and I get the error above.

8 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 29 Jan 2008, 08:44 AM
Hello Michael Onstad,

The DockState class is not serializable and this is why you get the specified error. What exactly is your scenario? Are you loading/saving the state in a database or in an XML? Our suggestions is to use the DockState's ToString method to save the state as a string and then load it with the Deserialize method.

Sincerely yours,
Petya
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Michael Onstad
Top achievements
Rank 1
answered on 29 Jan 2008, 09:26 PM
Hi,
Thanks for your reply. I'm saving the DocState to the database.

Im not seeing a deserialize method. Do you mean in BinaryFormatter?

I ended up creating a wrapper class that inherits DockState and ISerializable and then writing my own Serialize/Deserialize method. I got it to save the List<DocState> in one binary field column for each user.

Does your method save each DocState individually or all at once in one field?

I would like to know which method you think is better.

I began using your example of adding "widgit" user controls in the RadDock and I manage to save the state to the database. In your example, you temporarily put the RadDock in an update panel and then it gets moved to the zone selected from the dropdown.

I'm having a small issue now where it saves the added widgit before it gets moved to the zone.. When I add my widgit, it correctly puts it in the zone I selected. But when I refresh my page (to reload the state from the db), it shows my added widgit in the top left corner instead of the zone I selected. If I manually drag the widgit to the zone I want, it then saves it to the database.

An ideas on that one?




0
LeBear
Top achievements
Rank 1
answered on 29 Jan 2008, 11:21 PM
In my application, I'm converting the state to a string via:

DS_String = Dock.GetState().ToString()

and then storing that in the database.  When I restore the state, that's what I deserialize it via:

DS = DockState.Deserialize(DS_String)
Dock.ApplyState(DS)
0
Josh
Top achievements
Rank 1
answered on 30 Jan 2008, 01:40 AM
You mention in your code for the "MyPortal" example "Store the info about the added docks in the session. For real life applications we recommend using database or other storage medium for persisting this information."

How do we do that using the overall code structure? Have you got any code for example?

Thankyou
0
Michael Onstad
Top achievements
Rank 1
answered on 30 Jan 2008, 01:42 AM
Thanks Barry for that tip. It appears this method saves the state of each dock in a seperate column or row of the database. With my method, Im saving the state of all the docks in one field. It works great, except for when I initially add the dock to the page. It saves the location of the dock in the top left corner instead of the location the dock gets moved to when they select a dock zone.

0
Josh
Top achievements
Rank 1
answered on 30 Jan 2008, 03:52 AM
Ok well I got it going. It's probably not that bad of a method. Just puts the individual serialized DockStates into an array and then serializes the array into the database. Works alright.
0
LeBear
Top achievements
Rank 1
answered on 30 Jan 2008, 10:20 AM
Michael,

Without seeing your code, I can only guess of course...

It sounds like you're saving the state of the new dock before it gets its state from having been docked.  As such, I would suspect that you're doing this too early in the page lifecycle.  It's like loading a datagrid during page load, deleting a record during a postback event, and then seeing the deleted record still in the datagrid.

You might want to trigger the saving of your dock states in the SaveDockLayout event.  I was hoping to find some information online about the dock lifecycle, and I did.  Check out RadDock in the Page Life Cycle.  I found that very helpful, as well as the article, Dynamically Created Docks.

I hope that helps.
0
Petya
Telerik team
answered on 30 Jan 2008, 11:16 AM
Hello,

Just wanted to clarify that there exists an example demonstrating how to save/load the state of the docks from a database which can be found here. In the example the usage of the DockState's ToString and Deserialize methods is demonstrated.

Michael, for the specific problem you describe it seems to me that you are not saving/loading correctly the state to and from the database. If you continue to experience the same problem, please send us a simple running project which we will run to reproduce the problem and investigate why it appears.

Greetings,
Petya
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Dock
Asked by
Michael Onstad
Top achievements
Rank 1
Answers by
Petya
Telerik team
Michael Onstad
Top achievements
Rank 1
LeBear
Top achievements
Rank 1
Josh
Top achievements
Rank 1
Share this question
or