Problem with MaultiPage and Usercontrol

2 posts, 1 answers
  1. Christian
    Christian avatar
    97 posts
    Member since:
    Mar 2009

    Posted 14 Apr 2009 Link to this post

    We use RadTabStrip with 4 RadMultiPages but I doesn't get it work. the seon userControl gets loaded but isn't shown in the page.

    We change the tabs with a button in the webpage (Button1_Click):

        <telerik:RadTabStrip ID="RadTabStrip1" runat="server"  AutoPostBack="true" OnTabClick="RadTabStrip1_TabClick" MultiPageID="RadMultiPage1">  
                <telerik:RadTab id="Tab01" Value="1" runat="server" Text="Import" Selected="true"/>  
                <telerik:RadTab id="Tab02" Value="2" runat="server" Text="Feldzuordnung" /> 
                <telerik:RadTab id="Tab03" Value="3" runat="server" Text="Filtereinstellungen" /> 
                <telerik:RadTab id="Tab04" Value="4" runat="server" Text="Stammdatenabgleich" /> 
        <table cellspacing="0" cellpadding="0" width="850px" border="0">  
                <td class="TabsPanelTopBody">  
                <td class="TabsPanelMainBody">  
                    <asp:Panel ID="Panel1" runat="server">  
                        <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0">  
                            <telerik:RadPageView ID="RadPageView1" runat="server" /> 
                            <telerik:RadPageView ID="RadPageView2" runat="server" /> 
                            <telerik:RadPageView ID="RadPageView3" runat="server" /> 
                            <telerik:RadPageView ID="RadPageView4" runat="server" /> 

    code behind:
        Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
            If Me.CurrentControl <> String.Empty And CurrentControl <> "import.ascx" Then 
                'LoadMyUserControl(CurrentControl, Me.RadPageView2)  
                LoadMyUserControl(CurrentControl, RadTabStrip1.SelectedTab.PageView)  
            End If 
        End Sub 
        Public Property CurrentControl() As String 
                Dim obj As Object = Session("CurrentControl")  
                If obj Is Nothing Then Return String.Empty Else Return CStr(obj)  
            End Get 
            Set(ByVal value As String)  
                Session("CurrentControl") = value  
            End Set 
        End Property 
        Public Sub RadMultiPage1_PageViewCreated(ByVal sender As ObjectByVal e As Telerik.Web.UI.RadMultiPageEventArgs) Handles RadMultiPage1.PageViewCreated  
            If Not created Then 
                If CurrentControl = "" Or CurrentControl = "import.ascx" Then 
                    Dim userControlName As String = "import.ascx" 
                    LoadMyUserControl(userControlName, e.PageView)  
                    created = True 
                    Button1.Text = "Datei importieren" 
                End If 
                If CurrentControl = "MappingField.ascx" Then 
                    Dim userControlName As String = "MappingField.ascx" 
                    LoadMyUserControl(userControlName, Me.RadPageView2)  
                    'LoadMyUserControl(userControlName, e.PageView)  
                    created = True 
                    'Button1.Text = "Datei importieren"  
                End If 
            End If 
        End Sub 
        Private Sub LoadMyUserControl(ByVal controlName As StringByVal parent As Control)  
            Dim userControlID As String 
            userControlID = controlName  
            Dim MyControl As Object = LoadControl(controlName)  
            MyControl.ID = userControlID.Replace("/""").Replace("~""").Replace(".""_")  
            If controlName = "import.ascx" Then 
                'Dateityp 1=Stammdaten setzen  
                Dim objType As Type = MyControl.GetType 
                Dim p As PropertyInfo = objType.GetProperty("TYPE")  
                p.SetValue(MyControl, 1, Nothing)  
            End If 
            Me.CurrentControl = controlName  
        End Sub 
       Protected Sub Button1_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles Button1.Click  
            For index As Integer = 0 To Me.RadPageView1.Controls.Count - 1  
                Dim cc As Control = Me.RadPageView1.Controls(index)  
            For index As Integer = 0 To Me.RadPageView2.Controls.Count - 1  
                Dim cc As Control = Me.RadPageView2.Controls(index)  
            Dim actualCurrentControl = CurrentControl  
            If actualCurrentControl = "import.ascx" Then 
                Dim result As Boolean = CType(Me.RadPageView1.Controls(0), ISaveFunction).save(sender, e)  
                If result Then 
                    Button1.Text = "Feldzuordnung speichern" 
                    RadTabStrip1.SelectedIndex = RadTabStrip1.SelectedIndex + 1  
                    LoadMyUserControl("MappingField.ascx", RadTabStrip1.SelectedTab.PageView)  
                    'LoadMyUserControl("MappingField.ascx", Me.RadPageView2)  
                    'todo: Fehler ausgeben  
                End If 
            End If 
            If actualCurrentControl = "MappingField.ascx" Then 
                Dim c As Control = Me.RadPageView2.Controls(0)  
                Dim result As Boolean = CType(Me.RadPageView2.Controls(0), ISaveFunction).save(sender, e)  
                If result Then 
                    Button1.Text = "Filter setzen" 
                    RadTabStrip1.SelectedIndex = RadTabStrip1.SelectedIndex + 1  
                    LoadMyUserControl("Filter.ascx", RadTabStrip1.SelectedTab.PageView)  
                End If 
            End If 
        End Sub 

    Has someone the solution?

  2. Answer
    Paul avatar
    4281 posts

    Posted 14 Apr 2009 Link to this post

    Hello Christian,

    Please refer to the following examples for details on the matter.

    Dynamic RadPageView
    Load on Demand RadPageView

    In addition, all Telerik examples are available offline with your installation of RadControls.

    Kind regards,
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top