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

Tabstrip / Multipage Inside Custom Control

3 Answers 88 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Mick
Top achievements
Rank 1
Mick asked on 04 Nov 2008, 08:43 AM
Hi, I am attempting to use a Tabstrip / Multipage inside a custom control. I have created a simple control to illustrate the problem I am having.
using System;  
using System.Collections.Generic;  
using System.Text;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using Telerik.Web.UI;  
 
namespace BT.NIEA.StakeholderControls  
{  
    [ToolboxData("<{0}:TestTabStrip runat=server></{0}:TestTabStrip>")]  
    public class TestTabStrip : WebControl  
    {  
        protected override void OnInit(EventArgs e)  
        {  
            // Create a Panel  
            Panel pnlCreate = new Panel();  
            pnlCreate.Visible = true;  
            // Create a Tabs Strip  
            RadTabStrip ts = new RadTabStrip();  
 
            RadTab tab1 = new RadTab();  
            tab1.Text = "Basic Information";  
            tab1.Selected = true;  
 
            RadTab tab2 = new RadTab();  
            tab2.Text = "Address Details";  
 
            RadTab tab3 = new RadTab();  
            tab3.Text = "Optional Information";  
 
            ts.Tabs.Add(tab1);  
            ts.Tabs.Add(tab2);  
            ts.Tabs.Add(tab3);  
 
            // Create a Multipage  
            RadMultiPage rmpCreate = new RadMultiPage();  
            // Set the multipage ID of the tab strip  
            ts.MultiPageID = "rmpCreate";  
            rmpCreate.SelectedIndex = 0;  
 
            // Create a Page View  
            RadPageView pvPage1 = new RadPageView();  
            // Create a Button and add it to the PageView  
            Button myButton1 = new Button();  
            myButton1.Text = "Button 1";  
            pvPage1.Controls.Add(myButton1);  
 
            // Create a Page View  
            RadPageView pvPage2 = new RadPageView();  
            // Create a Button and add it to the PageView  
            Button myButton2 = new Button();  
            myButton2.Text = "Button 2";  
            pvPage2.Controls.Add(myButton2);  
 
            // Create a Page View  
            RadPageView pvPage3 = new RadPageView();  
            // Create a Button and add it to the PageView  
            Button myButton3 = new Button();  
            myButton3.Text = "Button 3";  
            pvPage3.Controls.Add(myButton3);  
 
            // Add the PageViews to Our Multi Page  
            rmpCreate.PageViews.Add(pvPage1);  
            rmpCreate.PageViews.Add(pvPage2);  
            rmpCreate.PageViews.Add(pvPage3);  
            // Add The TabStrip to Our Panel  
            pnlCreate.Controls.Add(ts);  
            // Add the MultiPage to the Panel  
            pnlCreate.Controls.Add(rmpCreate);  
            // Finally add the Panel to the Page  
            this.Controls.Add(pnlCreate);  
        }  
        protected override void Render(HtmlTextWriter writer)  
        {  
            base.Render(writer);  
        }  
    }  

This gives me a JavaScript error: 'undefined is null or not an object', and the tabstrip will not change multipage.
Could someone advise where I am going wrong please?

3 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 04 Nov 2008, 09:36 AM
Hi Mick,

Review the replies you received from my colleague in the other forum post you opened in regards with this subject:

http://www.telerik.com/community/forums/thread/b311D-btbeet.aspx

Best,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mick
Top achievements
Rank 1
answered on 04 Nov 2008, 09:44 AM
Stephen, thanks for your response, but I dont think the replies posted to my previous thread are valid due to the fact I am creating the TabStrip and multipage in the OnInit() method.

Any ideas?
0
Mick
Top achievements
Rank 1
answered on 04 Nov 2008, 10:07 AM
Appologies for my hasty response Stephen, I found if I reordered the control creation it works perfectly.
using System;  
using System.Collections.Generic;  
using System.Text;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using Telerik.Web.UI;  
 
namespace BT.NIEA.StakeholderControls  
{  
    [ToolboxData("<{0}:TestTabStrip runat=server></{0}:TestTabStrip>")]  
    public class TestTabStrip : WebControl  
    {  
        protected override void OnInit(EventArgs e)  
        {  
            UpdatePanel updatePanel = new UpdatePanel();  
            updatePanel.ID = "updatePanel";  
 
            // Create a Panel  
            Panel pnlCreate = new Panel();  
            pnlCreate.Visible = true;  
            this.Controls.Add(pnlCreate);  
            // Create a Tabs Strip  
            RadTabStrip ts = new RadTabStrip();  
            // Add The TabStrip to Our Panel  
            pnlCreate.Controls.Add(ts);  
            RadTab tab1 = new RadTab();  
            tab1.Text = "Basic Information";  
            tab1.Selected = true;  
 
            RadTab tab2 = new RadTab();  
            tab2.Text = "Address Details";  
 
            RadTab tab3 = new RadTab();  
            tab3.Text = "Optional Information";  
 
            ts.Tabs.Add(tab1);  
            ts.Tabs.Add(tab2);  
            ts.Tabs.Add(tab3);  
 
            // Create a Multipage  
            RadMultiPage rmpCreate = new RadMultiPage();  
            // Add the MultiPage to the Panel  
            pnlCreate.Controls.Add(rmpCreate);  
            // Set the multipage ID of the tab strip  
            ts.MultiPageID = rmpCreate.ClientID;  
            // Create a Page View  
            RadPageView pvPage1 = new RadPageView();  
            pvPage1.ID = "pvPage1";  
            // Create a Page View  
            RadPageView pvPage2 = new RadPageView();  
            pvPage2.ID = "pvPage2";  
            // Create a Page View  
            RadPageView pvPage3 = new RadPageView();  
            pvPage3.ID = "pvPage3";  
            // Add the PageViews to Our Multi Page  
            rmpCreate.PageViews.Add(pvPage1);  
            rmpCreate.PageViews.Add(pvPage2);  
            rmpCreate.PageViews.Add(pvPage3);  
            rmpCreate.SelectedIndex = 1;  
              
             
            // Create a Button and add it to the PageView  
            Button myButton1 = new Button();  
            myButton1.Text = "Button 1";  
            pvPage1.Controls.Add(myButton1);  
 
              
            // Create a Button and add it to the PageView  
            Button myButton2 = new Button();  
            myButton2.Text = "Button 2";  
            pvPage2.Controls.Add(myButton2);  
 
              
            // Create a Button and add it to the PageView  
            Button myButton3 = new Button();  
            myButton3.Text = "Button 3";  
            pvPage3.Controls.Add(myButton3);  
 
             
             
              
        }  
        protected override void Render(HtmlTextWriter writer)  
        {  
            base.Render(writer);  
        }  
        public override ControlCollection Controls  
        {  
            get 
            {  
                this.EnsureChildControls();  
                return base.Controls;  
            }  
        }  
    }  

Regards
Mick
Tags
TabStrip
Asked by
Mick
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Mick
Top achievements
Rank 1
Share this question
or