I suggest you ...

Nice way to define properties with StateContainer Attribute

StateContainer(ViewState)]

string FirstName
{
get;
set;
}

[StateContainer(Session)]
List<string> myList
{
get;set;
}

[StateContainer(Cache)]
List<string> myList2
{
get;set;
}

Just a random thought: I think it would be nice, with the help of an attribute, to be able to define where a given property would be stored.

I guess it also be applied at the class level, if you want all of your properties to inherti the same StateContainer Attribute.

A change probably best fit for an upcoming Framework release.

Just a thought.

27 votes
Vote
Sign in
(thinking…)
Password icon
Signed in as (Sign out)
You have left! (?) (thinking…)
Nauman shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

2 comments

Sign in
(thinking…)
Password icon
Signed in as (Sign out)
Submitting...
  • Irfan commented  ·   ·  Flag as inappropriate

    Also be nice if we could name the variable in session, cookie etc which can be different then the property name.

    StateContainer(Session, "FirstMidName")]
    string FirstName { get; set; }

  • Gc-2011 commented  ·   ·  Flag as inappropriate

    Wonderful idea. I strongly recommend this, specially for properties of web-pages :

    [StateContainer("Session")]
    public List<MyClass> MyPageData {get; set;}

Feedback and Knowledge Base