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

Derived RadPageView is wrong type when loaded from ViewState

4 Answers 50 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Mats
Top achievements
Rank 1
Mats asked on 18 Oct 2010, 04:41 PM
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

4 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 22 Oct 2010, 09:45 AM
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
0
Mats
Top achievements
Rank 1
answered on 25 Oct 2010, 12:06 PM
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
0
Yana
Telerik team
answered on 25 Oct 2010, 01:26 PM
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
0
Shark75
Top achievements
Rank 2
answered on 30 Jan 2014, 11:51 AM
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();
    }
}

Tags
TabStrip
Asked by
Mats
Top achievements
Rank 1
Answers by
Yana
Telerik team
Mats
Top achievements
Rank 1
Shark75
Top achievements
Rank 2
Share this question
or