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

Not getting persistance in usercontrol to work

4 Answers 54 Views
Persistence Framework
This is a migrated thread and some comments may be shown as answers.
C
Top achievements
Rank 1
C asked on 10 Sep 2014, 08:31 AM
I have a usercontrol, categoryTree, for which I want to save it's state (namely whether checkboxes in a RadTreeView are checked) across sessions. So I have added this to the main page:

<telerik:RadPersistenceManager ID="RadPersistenceManager1" runat="server">
    </telerik:RadPersistenceManager>

And this to categoryTree.aspx:

‚Äč<telerik:RadPersistenceManagerProxy ID="RadPersistenceManagerProxy1" runat="server">
    <PersistenceSettings>
        <telerik:PersistenceSetting ControlID="RadTreeView1" />
    </PersistenceSettings>
</telerik:RadPersistenceManagerProxy>

And this to the codebehind:

private RadPersistenceManager _persistenceManager;

protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            _persistenceManager = RadPersistenceManager.GetCurrent(Page);
            if (!IsPostBack)
                _persistenceManager.LoadState();
        }


(and in the event for checked nodes):

_persistenceManager.SaveState();

But after I restart the page, the previous state does not get loaded. What am I missing?

4 Answers, 1 is accepted

Sort by
0
C
Top achievements
Rank 1
answered on 10 Sep 2014, 09:24 AM
I have also tried doing the save and load in the main page's Page_Load and Page_PreRender. But nothing happens.

What else needs to happen before the data persists?
0
Peter Filipov
Telerik team
answered on 15 Sep 2014, 07:48 AM
Hi,

Please review the attached project. It implements the desired functionality. Keep in mind that for the first start of your application there should be a file (TelerikAspNetRadControlsPersistedState) in the App_data folder.

Regards,
Peter Filipov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
C
Top achievements
Rank 1
answered on 15 Sep 2014, 09:23 AM
I actually managed to save the state by myself. However, I am now struggling with the following:

I save the state of a RadListBox, which in turn filters events for a RadScheduler. However, I haven't been able to make the scheduler use the state of the listbox before it's first load.

That is, the first time the page loads, the filter settings are correct (checkboxes), but the data in the scheduler does not reflect this.
0
C
Top achievements
Rank 1
answered on 15 Sep 2014, 12:03 PM
Nevermind, I think I've solved it.
Tags
Persistence Framework
Asked by
C
Top achievements
Rank 1
Answers by
C
Top achievements
Rank 1
Peter Filipov
Telerik team
Share this question
or