Not logged in - Login

Create property that saves to ViewState

The following illustrates how to create a property that saves data to the ViewState on a web page.

private string FunctionalCurrency
{
   get
   {
      string keyName = System.Reflection.MethodBase.GetCurrentMethod().Name.Substring(4);
      string rv = this.ViewState[keyName].SafeStringAssign();

      return rv;
   }
   set
   {
      string keyName = System.Reflection.MethodBase.GetCurrentMethod().Name.Substring(4);
      this.ViewState[keyName] = value;
   }
}