Deserialization Problem

2 posts, 0 answers
  1. debett
    debett avatar
    30 posts
    Member since:
    Feb 2007

    Posted 15 May 2009 Link to this post

    Dear all,

    I am serializing the state of my docks using xml serializer (also tried javascriptserializer).
    However, not all the values are deserialized correctly. For instance, width and height of the docks are being lost.

    This is an example of the object before serialization and after deserialization:

    +  [0] {"UniqueName":"5eb163f6a40aaa4e42a8b15a3c768b30db0f","DockZoneID":"ctl00_contentpane_Top","Width":"250px","Height":"250px","ExpandedHeight":"0","Top":"0px","Left":"0px","Resizable":"False","Closed":"False","Collapsed":"False","Pinned":"False","Title":"Campaigns Distribution(Promised)","Text":"Added at 5/15/2009 12:40:52 PM","Tag":"~/Development/Controls/DeveloperCampaignDistribution.ascx","Index":"0"} Telerik.Web.UI.DockState
    -  [0] {"DockZoneID":"ctl00_contentpane_Top","Width":"","ExpandedHeight":"0","Height":"","Index":"0","Top":"","Left":"","Closed":"False","Resizable":"False","Collapsed":"False","Pinned":"False","UniqueName":"5eb163f6a40aaa4e42a8b15a3c768b30db0f","Tag":"~/Development/Controls/DeveloperCampaignDistribution.ascx","Title":"Campaigns Distribution(Promised)","Text":"Added at 5/15/2009 12:40:52 PM"} Telerik.Web.UI.DockState

    How can I restore the width?
    If you need code example, you can find it the previous support ticket.

    Thank you.
  2. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 18 May 2009 Link to this post

    "The problem comes from the fact that the Unit object cannot be serialized.  This means that once the object has been serialized and then deserialized, the properties such as Top, Left, Width and Height etc. will loose their values.
    Please note that this has nothing to do with Telerik components but with the .NET Framework and missing serialization.This is a shortcoming of the .Net Framework but it could be overcomed. For example you could use the JavaScriptSerializer class to serialize the state of the docks and write your own implementation of a custom JavaScriptConverter class. This custom class will take care of serialization/deserialization of Unit objects."
    You can find attached an example in this forum thread.
    Another approach is to use ToString() - serialize, and  DockState.Deserialize(currentStateString); methods
    e.g.
    string stateString = String.Empty;  
            //Serialize all states in stateString  
            foreach (DockState state in RadDockLayout1.GetRegisteredDocksState())  
            {  
                stateString = stateString + state.ToString() + "|";  
            }  
            //Deserialize  
            string[] states = stateString.Split('|');  
            foreach (string currentStateString in states)  
            {  
                DockState currentState = DockState.Deserialize(currentStateString);  
            } 
     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top