SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom control that inherits from PeopleEditor in my WebPart. In the custom control I have a custom property:

public string MyProperty
                string text = (string)ViewState["myKey"];
                if (text != null)
                    return text;
                    return string.Empty;
                ViewState["myKey"] = value;

I set this property while OnInit of my WebPart. But after post back of this control ViewState comes without my property, it even doesn't contain myKey in the Keys.

Do you have any ideas how to creat a custom property which will not be lost after post back?

share|improve this question
Do you use that by visual webpart in sandboxed solutions? I remember that the viewstate not work in sandboxed webparts. – Sascha Apr 11 '13 at 10:05
No, I use it in a visual webpart in a farm solution. – alisa Apr 11 '13 at 11:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.