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?

  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.