giammin

Devexpress cookie grid layout

May 4th, 2012
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1.  <%-- il CookiesID deve sempre iniziare per DevExpress_ ed essere diverso per ciascuna griglia del sito dove lo si utilizza
  2. Bisogna anche aggiungere l'evento Session_Start nel global.asax--%>
  3. <SettingsCookies Enabled="True" CookiesID="DevExpress_NOMEGRIGLIA" StoreColumnsVisiblePosition="True" StoreColumnsWidth="True" StoreFiltering="True" StoreGroupingAndSorting="True" StorePaging="True" />
  4.              
  5.     void Session_Start(object sender, EventArgs e)
  6.        {
  7.            base.Application_AuthenticateRequest(sender, e);
  8.            if (Context.User != null &&
  9.                (Context.User.IsInRole(Role.AdminRoleName) || Context.User.IsInRole(Role.ProsperoRoleName)))
  10.            {
  11.                var keyColl = Context.Request.Cookies.AllKeys;
  12.  
  13.                for (int i=0;i<keyColl.Length;i++)
  14.                {
  15.                    if (keyColl[i].StartsWith("DevExpress_",StringComparison.OrdinalIgnoreCase))
  16.                    {
  17.                        var httpCookie = Context.Request.Cookies[keyColl[i]];
  18.                        if (httpCookie != null)
  19.                        {
  20.                            httpCookie.Expires = DateTime.Now.AddDays(-1);
  21.                            Context.Response.Cookies.Add(httpCookie);
  22.                        }
  23.                    }
  24.                }
  25.            }
  26.        }
Advertisement
Add Comment
Please, Sign In to add comment