More in this section

Forums / General Discussions / ViewState does not work

ViewState does not work

2 posts, 0 answered
  1. John Hunter
    John Hunter avatar
    4 posts
    07 Aug 2012
    01 Dec 2010
    Link to this post
    I have created an ascx control in which I try to place a simple object into viewstate for use on postback's for this my control.  When I place an object into viewstate, it exists a few lines later when I update it.  However on postbacks, the viewstate is always empty on my button click event handler.  I read in another post that I needed to enable viewstate in my master page.  When I placed 'this.Page.EnableViewState = true;' in my Masterpage OnInit event, i receievd a new error stating that my simple object needed to have the [Serializable] attribute.  I added the attribute, but the view state is still empty on postback.

    What else should I try to resolve this.
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    01 Feb 2016
    02 Dec 2010
    Link to this post
    Hi John Hunter,

    Thank you for using our services.

    Can you please show us the full code you are using the OnInit event? This should not require serializable attribute. We have logged this issue for fixing (#66613) and will soon provide an option to set this from page properties in settings.

    Kind regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered