Derived RadPageView is wrong type when loaded from ViewState

5 posts, 0 answers
  1. Mats
    Mats avatar
    66 posts
    Member since:
    Aug 2006

    Posted 18 Oct 2010 Link to this post

    Hi!

    I have my own derived version of RadPageView that will add some features:

        public class TRadPageView : RadPageView
        {

             ...
        }

    I have a RadMultiPage holding my TRadTabViews (in RadMultiPage.PageViews).
    When the RadMultiPage is loaded from ViewState then sometimes my instances of TRadPageView will be loaded as instances of RadPageView instead of TRadPageView!

    Does anyone know how to force the ViewState of RadMultiPage.PageViews to be loaded with my derived instances of RadPageView?

    Thanks
    /Mats

  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 22 Oct 2010 Link to this post

    Hello Mats,

    This is expected behavior as RadMultiPage expects child controls of type RadPageView.  The solution is to
    inherit also the multipage and override its CreatePageView method. I've attached a very simple implementation of the approach. Please download the attached file and give it a try.

    Regards,
    Yana
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mats
    Mats avatar
    66 posts
    Member since:
    Aug 2006

    Posted 25 Oct 2010 Link to this post

    Hello Yana!

    Exactly what I was looking for.
    I already have a derived MultiPage class so it will be easy to implement. But I'm still running version 2010.1.519.20 and the CreatePageView method is not available in that version (that's why I did not find it myself).
    I will soon move to latest version of controls so that will fix my problem.

    Thanks
    /Mats
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 25 Oct 2010 Link to this post

    Hello Mats,

    I'm glad I could help.

    Regards,
    Yana
    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
  6. Shark75
    Shark75 avatar
    32 posts
    Member since:
    Apr 2007

    Posted 30 Jan 2014 Link to this post

    I've been trying to sub-class the RadPageView and RadMultiPage classes, but have run into the same problem with the ViewState not being remembered for controls within the page view. These controls are defined in the markup and not dynamically loaded or created as are the page views and multipages. The only "special" thing I'm doing is automatically adding a validation summary control dynamically in the page view code.

    Is there something else we need to do to get ViewState to work for the controls inside the page views?

    public class CMSMultiPage : RadMultiPage
    {
        public CMSMultiPage()
        {
            this.SelectedIndex = 0;
            this.CssClass = "RadMultiPage_CMS";
        }
     
        protected override RadPageView CreatePageView()
        {
            return new CMSPageView();
        }
    }
     
    public class CMSPageView : RadPageView
    {
        public CMSPageView()
        {
            this.CssClass = "RadPageView_CMS";
            this.DisplayCMSValidationSummary = true;
        }
     
        // Adds a CMSValidationSummary control to the CMSPageView.
        public bool DisplayCMSValidationSummary;
     
        protected override void CreateChildControls()
        {
            if (this.DisplayCMSValidationSummary)
            {
            // Add a CMSValidationSummary to the controls list.
            this.Controls.AddAt(0, new CMSValidationSummary());
            }
     
            base.CreateChildControls();
        }
    }

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017