Cannot Save Dock State To Database/Prometheus

9 posts, 0 answers
  1. Michael Onstad
    Michael Onstad avatar
    14 posts
    Member since:
    Jan 2006

    Posted 27 Jan 2008 Link to this post


    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.
  2. Petya
    Admin
    Petya avatar
    869 posts

    Posted 29 Jan 2008 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Michael Onstad
    Michael Onstad avatar
    14 posts
    Member since:
    Jan 2006

    Posted 29 Jan 2008 Link to this post

    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?




  5. LeBear
    LeBear avatar
    233 posts
    Member since:
    May 2006

    Posted 29 Jan 2008 Link to this post

    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)
  6. Josh
    Josh avatar
    5 posts
    Member since:
    Jan 2008

    Posted 29 Jan 2008 Link to this post

    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
  7. Michael Onstad
    Michael Onstad avatar
    14 posts
    Member since:
    Jan 2006

    Posted 29 Jan 2008 Link to this post

    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.

  8. Josh
    Josh avatar
    5 posts
    Member since:
    Jan 2008

    Posted 29 Jan 2008 Link to this post

    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.
  9. LeBear
    LeBear avatar
    233 posts
    Member since:
    May 2006

    Posted 30 Jan 2008 Link to this post

    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.
  10. Petya
    Admin
    Petya avatar
    869 posts

    Posted 30 Jan 2008 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017