More in this section

Forums / Developing with Sitefinity / Added New LinkButtons to Users.aspx Now Get ViewState Error

Added New LinkButtons to Users.aspx Now Get ViewState Error

3 posts, 0 answered
  1. mrbowling
    mrbowling avatar
    15 posts
    Registered:
    24 Apr 2007
    08 Jan 2010
    Link to this post
    I added think linkbuttons to User.aspx and then in the OnInit I set them up with this code

    1     protected override void OnInit(EventArgs e) 
    2     { 
    3         base.OnInit(e); 
    4         manageUsers.ModeChanged += new EventHandler(manageUsers_ModeChanged); 
    5         manageUsers.CreatedRole += new RoleCreatedEventHandler(manageUsers_CreatedRole); 
    6  
    7         Control container = manageUsers.GetCurrentContainer(); 
    8  
    9         //acceptSelectedBtn = (IButtonControl)this.FindTypedControl("AcceptSelected", typeof(IButtonControl)); 
    10         acceptBOSelectedBtn = (IButtonControl)container.FindControl("AcceptBOSelected"); 
    11         if (acceptBOSelectedBtn != null
    12         { 
    13             acceptBOSelectedBtn.CommandName = "AcceptBOSelected"
    14             acceptBOSelectedBtn.Command += new CommandEventHandler(this.AcceptBOSelected_Command); 
    15         } 
    16  
    17         acceptGWSelectedBtn = (IButtonControl)container.FindControl("AcceptGWSelected"); 
    18         if (acceptGWSelectedBtn != null
    19         { 
    20             acceptGWSelectedBtn.CommandName = "AcceptGWSelected"
    21             acceptGWSelectedBtn.Command += new CommandEventHandler(this.AcceptGWSelected_Command); 
    22         } 
    23  
    24         rejectSelectedBtn = (IButtonControl)container.FindControl("RejectSelected");  
    25         if (rejectSelectedBtn != null
    26         { 
    27             rejectSelectedBtn.Command += new CommandEventHandler(this.RejectSelected_Command); 
    28             rejectSelectedBtn.CommandName = "RejectSelected"
    29         } 
    30  
    31   
    32     } 


    And now I get this error when going to a profile and coming back (either view save or cancel or even the back button at top)

    1  Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request. 
    2 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    3  
    4 Exception Details: System.Web.HttpException: Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request. 
    5  
    6 Source Error: 
    7  
    8 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 
    9  
    10 Stack Trace: 
    11  
    12 [HttpException (0x80004005): Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.] 
    13    System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +11028933 
    14    System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +232 
    15    System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +395 
    16    System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +232 
    17    System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +395 
    18    System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +232 
    19    System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +395 
    20    System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +232 
    21    System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +395 
    22    System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +232 
    23    System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +395 
    24    System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +232 
    25    System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +395 
    26    System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +232 
    27    System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +395 
    28    System.Web.UI.Page.LoadAllState() +564 
    29    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1864 
    30  



  2. mrbowling
    mrbowling avatar
    15 posts
    Registered:
    24 Apr 2007
    08 Jan 2010
    Link to this post
    added to Page_Load works fine now.
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Jan 2010
    Link to this post
    Hello mrbowling,

    You can use OnPreRender as well.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
3 posts, 0 answered