Question

I'm developing a website that has a homepage with several RadDocks where users can select particular controls they want to be displayed and they can arrange it how the like.

I was getting lots of viewstate errors when adding/moving/removing (control tree changed) and the only solutions seems to be creating wrapper classes for some of the telerik contols (RadDock, RadDockLayout, RadDockZone etc) and applying the [ViewStateModeById] attribute.

[ViewStateModeById]
public class RadDockById : RadDock

Has anyone used RadDock in conjunction with ViewStateModeById? Is it likely to cause any trouble down the line?

Was it helpful?

Solution

The ViewState related problems that you have encountered are most probably caused by the following two things:

  1. The dynamically created RadDock's are not added to the same control. Once they are added to the RadDockZone's and other times to RadDockLayout. This causes the incorrect ViewState to be loaded for some of the docks which is causing the problem.
  2. The closed docks are disposed and removed from the page. This again changes the Controls tree of the Page, which is essential when loading and saving the ViewState.

You have the following options in resolving the issue on your side:

  • Disabling the ViewState for the RadDockLayout or entire page. This way you can add or remove controls, but if the properties are changed dynamically there might be some problems.
  • Creating a new class that inherits from the RadDock control and marking it to use ViewStateModeById, as you have guessed. In this forum thread you can find more information about this approach.
  • At all times creating all docks and adding them to the RadDockLayout. The closed RadDocks should always have their Visible property set to false.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top