How to save per user/machine?

4 posts, 0 answers
  1. John Reynolds
    John Reynolds avatar
    32 posts
    Member since:
    Sep 2008

    Posted 14 Mar 2013 Link to this post

    We've been using the GridSettingsPersister provided in the help here.
    What must be done to save the settings per user or per machine in a similar fashion with the new persistence framework?
    
    Regards,
    
    John
  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 20 Mar 2013 Link to this post

    Hi John,

    Find attached a sample application which demonstrates possible approach for achieving the required functionality.

    I hope this helps.

    Greetings,
    Maria Ilieva
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vasssek
    Vasssek avatar
    143 posts
    Member since:
    Aug 2010

    Posted 14 Apr 2013 Link to this post

    Hello,

    FYI, in your example there isn't used the Expires property, that's why a cookie persists only during session. That means, when user closes browser and start app again, the cookie is lost.

    If you want to have cookie persisted, just add line marked bold:
    public void SaveStateToStorage(string key, string serializedState)
        {
            HttpCookie cookie = new HttpCookie(StorageKey);
            cookie.Expires = DateTime.Now.AddYears(1);
            string settingsData = CompressString(serializedState);
     
            if (settingsData.Length > MaxCookieSize)
            {
                throw new ArgumentOutOfRangeException("Current settings exceed 4k in compressed form! Operation canceled!");
            }
     
            cookie.Value = settingsData;
     
            HttpContext.Current.Response.Cookies.Add(cookie);
        }

    Best regards

    Vasssek
  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 16 Apr 2013 Link to this post

    Hi Vaclav,

    Thank you for pointing this. I'm sure it will be of a big help for the other users trying to implement similar scenarios.


    Regards,
    Maria Ilieva
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top