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

Load/Save to DB Error with JavaScriptSerializer

1 Answer 32 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 25 Sep 2008, 09:56 AM
HI,
I am trying to use this code supplied in another post
Protected Sub RadDockLayout1_SaveDockLayout(ByVal sender As ObjectByVal e As Telerik.Web.UI.DockLayoutEventArgs)   
    Dim dockState As String   
    Dim serializer As New Script.Serialization.JavaScriptSerializer()   
    Dim stateList As List(Of DockState) = RadDockLayout1.GetRegisteredDocksState()   
    Dim serializedList As New StringBuilder()   
    Dim i As Integer = 0   
    While i < stateList.Count   
        serializedList.Append(serializer.Serialize(stateList(i)))   
        serializedList.Append("|")   
        i += 1   
    End While   
    dockState = serializedList.ToString()   
    'Save the dockState string into DB   
End Sub   
 
protected Sub RadDockLayout1_LoadDockLayout(ByVal sender As ObjectByVal e As Telerik.Web.UI.DockLayoutEventArgs)  
    Dim serializer As New Script.Serialization.JavaScriptSerializer()   
    'Get saved state string from the database - set it to dockState variable for example   
    Dim currentDockStates As String() = dockState.Split("|")   
    For Each stringState As String In currentDockStates   
        If stringState <> String.Empty Then   
             Dim state As DockState = serializer.Deserialize(Of DockState)(stringState)   
             e.Positions(state.UniqueName) = state.DockZoneID   
             e.Indices(state.UniqueName) = state.Index   
        End If   
    Next 
End Sub 

however, i am getting..
Warning 2 'Public Sub New()' is obsolete: 'The recommended alternative is System.Runtime.Serialization.DataContractJsonSerializer.'. 

Any ideas ?
Thanks
Mark

1 Answer, 1 is accepted

Sort by
0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 29 Sep 2008, 02:51 PM
Please take a look at the following forum thread:
http://www.telerik.com/community/forums/thread/b311D-bkdgdg.aspx

"I prepared a sample project which demonstrates how you could modify the Dynamically Created Docks example so that it saves the state into Database. Please, take a look at the attached archive and let us know in case you still experience any problems.

Best regards,
Sophy
"

Hope this helps!
Tags
Dock
Asked by
Mark
Top achievements
Rank 1
Answers by
Obi-Wan Kenobi
Top achievements
Rank 1
Share this question
or