شركة التطبيقات المتكاملة لتصميم النظم البرمجية الخاصة

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » View

Public general use code classes and xml files that we've compiled and used over the years:

ASP.NET state support functions: Applications, Session, Coockies, Control.

   1:  using System;
   2:  using System.Web;
   3:  using System.Web.UI;
   4:   
   5:  namespace Ia.Cl.Model.AspNetState
   6:  {
   7:      ////////////////////////////////////////////////////////////////////////////
   8:   
   9:      /// <summary publish="true">
  10:      /// ASP.NET state support functions: Applications, Session, Coockies, Control.
  11:      /// </summary>
  12:      /// <value>
  13:      /// https://msdn.microsoft.com/en-us/library/z1hkazw7(v=vs.100).aspx
  14:      /// </value>
  15:      /// <remarks> 
  16:      /// Copyright © 2001-2015 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  17:      ///
  18:      /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
  19:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  20:      ///
  21:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  22:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  23:      /// 
  24:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  25:      /// 
  26:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  27:      /// </remarks> 
  28:      public class View
  29:      {
  30:          public View() { }
  31:   
  32:          public static void Write(StateBag viewState, string name, object value)
  33:          {
  34:              viewState[name] = value;
  35:          }
  36:   
  37:          public static object Read(StateBag viewState, string name)
  38:          {
  39:              return viewState[name];
  40:          }
  41:      }
  42:   
  43:      ////////////////////////////////////////////////////////////////////////////
  44:      ////////////////////////////////////////////////////////////////////////////
  45:   
  46:   
  47:   
  48:   
  49:   
  50:   
  51:      ////////////////////////////////////////////////////////////////////////////
  52:      ////////////////////////////////////////////////////////////////////////////
  53:   
  54:      /// <summary>
  55:      ///
  56:      /// </summary>
  57:      public class Control
  58:      {
  59:          public Control() { }
  60:      }
  61:   
  62:      ////////////////////////////////////////////////////////////////////////////
  63:      ////////////////////////////////////////////////////////////////////////////
  64:   
  65:   
  66:   
  67:   
  68:   
  69:   
  70:      ////////////////////////////////////////////////////////////////////////////
  71:      ////////////////////////////////////////////////////////////////////////////
  72:   
  73:      /// <summary>
  74:      ///
  75:      /// </summary>
  76:      public class Cookie
  77:      {
  78:          ////////////////////////////////////////////////////////////////////////////
  79:   
  80:          /// <summary>
  81:          ///
  82:          /// </summary>
  83:          public Cookie() { }
  84:   
  85:          ////////////////////////////////////////////////////////////////////////////
  86:   
  87:          /// <summary>
  88:          ///
  89:          /// </summary>
  90:          public static void Write(string name, string value)
  91:          {
  92:              Write(name, value, 9999);
  93:          }
  94:   
  95:          ////////////////////////////////////////////////////////////////////////////
  96:   
  97:          /// <summary>
  98:          ///
  99:          /// </summary>
 100:          public static void Write(string name, string value, int lifeInDays)
 101:          {
 102:              // this appends a cookie to the collection
 103:   
 104:              HttpCookie cookie = new HttpCookie(name, value);
 105:   
 106:              cookie.Expires = DateTime.UtcNow.AddHours(3 + 24 * lifeInDays);
 107:   
 108:              HttpContext.Current.Response.Cookies.Add(cookie);
 109:          }
 110:   
 111:          ////////////////////////////////////////////////////////////////////////////
 112:   
 113:          /// <summary>
 114:          ///
 115:          /// </summary>
 116:          public static string Read(string name)
 117:          {
 118:              // this reads the value of the cookie
 119:              string value;
 120:              HttpCookie cookie;
 121:   
 122:              cookie = HttpContext.Current.Request.Cookies[name];
 123:   
 124:              if (cookie == null) value = null;
 125:              else value = cookie.Value;
 126:   
 127:              return value;
 128:          }
 129:   
 130:          ////////////////////////////////////////////////////////////////////////////
 131:          ////////////////////////////////////////////////////////////////////////////
 132:   
 133:   
 134:   
 135:   
 136:   
 137:   
 138:   
 139:   
 140:          ////////////////////////////////////////////////////////////////////////////
 141:          ////////////////////////////////////////////////////////////////////////////
 142:   
 143:          /// <summary>
 144:          ///
 145:          /// </summary>
 146:          public class Application
 147:          {
 148:              public Application() { }
 149:          }
 150:   
 151:          ////////////////////////////////////////////////////////////////////////////
 152:          ////////////////////////////////////////////////////////////////////////////
 153:   
 154:   
 155:   
 156:   
 157:   
 158:   
 159:          ////////////////////////////////////////////////////////////////////////////
 160:          ////////////////////////////////////////////////////////////////////////////
 161:   
 162:          /// <summary>
 163:          ///
 164:          /// </summary>
 165:          public class Session
 166:          {
 167:              public Session() { }
 168:          }
 169:   
 170:          ////////////////////////////////////////////////////////////////////////////
 171:          ////////////////////////////////////////////////////////////////////////////
 172:   
 173:      }
 174:  }