This is a migrated thread and some comments may be shown as answers.

User Control inside RadAjaxManager

1 Answer 74 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Abhishek
Top achievements
Rank 1
Abhishek asked on 16 Jan 2012, 12:08 PM

My Asp Panel has a usercontrol inside it...User control is dynamicaly loaded.
Asp panel is placed inside RadAjaxManager..
User control contains drop down list and text boxes..

on page load user control is loaded...
But when I change selected index of drop down list inside user control...and do a postback....I receive an error...
which says...

"Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: 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."

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 16 Jan 2012, 04:22 PM
Hi Abhishek,

The reason for the error you are getting could be due to incorrect loading of the UserControls. If you are switching UserControls before the ViewState is loaded, ASP.NET will try to load the ViewState from the previously loaded user control into the new one. Thus, as the controls collection of the two does not match, an exception will thrown.
For example if you are changing the userControl on a button click event you should load the new UserControls inside the button's click handler and use Page's Init event to load the same UserControl which has been loaded in the previous page request.

I would also suggest you to review the following online resources which elaborates on Loading UserControls with Ajax:
http://www.telerik.com/help/aspnet-ajax/ajax-load-user-controls.html
http://demos.telerik.com/aspnet-ajax/ajax/examples/common/loadingusercontrols/defaultcs.aspx


All the best,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Ajax
Asked by
Abhishek
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or