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

A Typical Problem. Plz. Help!!

6 Answers 154 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Nilachandan
Top achievements
Rank 1
Nilachandan asked on 16 Oct 2008, 09:02 AM

Hi Paul

I am facing a typical problem.
I am creating RadTabStrips dynamically with each one containing a separate webcontrol. For navigating between tabs I use buttons. On clicking I am able to navigate between the tabs.
But, if I am putting the entire thing inside a RADDOCK, on clicking the button an error message "Object Reference Not Set To An Instance of An Object" gets displayed.
Please find the code snippet below (Red Colored Line is giving the error):

private void GoToNextTab()
    {
        try
        {
            RadTabStrip tabStrip = (RadTabStrip)Page.FindControl("ForumRadTabStrip");
            RadTab professionalInfoTab = tabStrip.FindTabByText("Create New");          
                  
            //professionalInfoTab.Enabled = true;
            //professionalInfoTab.Selected = true;
        }
        catch (Exception ex)
        {
            LinkButton1.Text = ex.Message;
        }
    }

6 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 20 Oct 2008, 12:38 PM
Hello Nilachandan,

Please find below a sample code snippet that shows the needed approach.

ASPX:
<form id="form1" runat="server">  
    <div> 
        <asp:ScriptManager ID="ScriptManager1" runat="server">  
        </asp:ScriptManager> 
    </div> 
    <telerik:RadDockLayout runat="server" ID="RadDockLayout1">  
        <telerik:RadDockZone runat="server" ID="RadDockZone2" Style="float: left; background: #d5f0fa;" Width="500" MinHeight="100">  
            <telerik:RadDock runat="server" ID="RadDock3" Title="ContentTemplate">  
                <ContentTemplate> 
                    <telerik:RadTabStrip ID="RadTabStrip1" runat="server">  
                        <Tabs> 
                            <telerik:RadTab runat="server" Text="Root RadTab1">  
                            </telerik:RadTab> 
                            <telerik:RadTab runat="server" Text="Root RadTab2">  
                            </telerik:RadTab> 
                            <telerik:RadTab runat="server" Text="Root RadTab3">  
                            </telerik:RadTab> 
                        </Tabs> 
                    </telerik:RadTabStrip> 
                    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> 
                </ContentTemplate> 
            </telerik:RadDock> 
            <telerik:RadDock runat="server" ID="RadDock4" Title="ContentContainer">  
            </telerik:RadDock> 
        </telerik:RadDockZone> 
    </telerik:RadDockLayout> 
</form> 

Code-behind:
protected void Button1_Click(object sender, EventArgs e)  
{  
    try 
    {  
        RadTabStrip tabStrip = (RadTabStrip)RadDock3.ContentContainer.FindControl("RadTabStrip1");  
        RadTab professionalInfoTab = tabStrip.FindTabByText("Root RadTab2");  
          
        professionalInfoTab.Enabled = true;  
        professionalInfoTab.Selected = true;  
    }  
    catch (Exception ex)  
    {  
        Button1.Text = ex.Message;  
    }  


Regards,
Paul
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Nilachandan
Top achievements
Rank 1
answered on 20 Oct 2008, 03:03 PM
Hi Paul

Thank your for reply. It did work wonderfully.
But I am facing problem, when I am shifting the RadTabStrip to another User Control.
Let me explain it, so that it will be easy for you to find out.

I have lets say, four pages.

Defult.aspx
mainUserControl.ascx
PersonalCS.ascx(For Dynamic Tab)
EducationCS.ascx(For Dynamic Tab)

In Defult.aspx, I have RadDock3 which contain user control mainUserControl.ascx.
In mainUserControl.ascx, I have RadTabStrip1 in which I am creating dynamic tabs with each one containing a separate webcontrol like PersonalCS.ascx and EducationCS.ascx. Everything works fine upto this.

Now to navigate from Personal tab to Education tab I have a button placed in PersonalCS.ascx as described before. When I click the button, error  "Object Reference Not Set To An Instance of An Object" is diplaying. It is comming from the following line.

RadTabStrip tabStrip = (RadTabStrip)RadDock3.ContentContainer.FindControl("RadTabStrip1");

How to get "RadTabStrip1" which is in mainUserControl.ascx at PersonalCS.ascx.
Again to make you remember, RadDock is in Default.aspx which contain mainUserControl.ascx.
 
Regards,
Chandan
0
Atanas Korchev
Telerik team
answered on 20 Oct 2008, 04:15 PM
Hi Nilachandan,

Since the tabstrip is inside an user control (and not in the dock) you should try this:

RadTabStrip tabStrip = (RadTabStrip)RadDock3.ContentContainer.FindControl("mainUserControl").FindControl("RadTabStrip1");
Best wishes,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Nilachandan
Top achievements
Rank 1
answered on 21 Oct 2008, 05:53 AM
Hi Paul/Albert

Thanx. Its working. Now my query is...
If I put default.aspx inside a master page then the same is not working.

I have lets say, Five pages instead of Four.

HomeMaster.master
Defult.aspx
mainUserControl.ascx
PersonalCS.ascx(For Dynamic Tab)
EducationCS.ascx(For Dynamic Tab)

Now everything else remain same. Then how to get the RadTabStrip. Because the code that you have suggested is not working in this case. Error "Object Reference Not Set To An Instance of An Objectis displaying again in this line.

RadTabStrip tabStrip = (RadTabStrip)RadDock3.ContentContainer.FindControl("mainUserControl").FindControl("RadTabStrip1");

How to get that?

Regards,
Chandan
0
Oscar
Top achievements
Rank 1
answered on 14 Mar 2009, 04:59 PM
How do I do this in VB.NET?
0
Poul Henningsen
Top achievements
Rank 1
answered on 16 Mar 2009, 01:26 PM
You can easily convert any C# code to VB.NET using some code converter. Telerik has such converter here.
Tags
TabStrip
Asked by
Nilachandan
Top achievements
Rank 1
Answers by
Paul
Telerik team
Nilachandan
Top achievements
Rank 1
Atanas Korchev
Telerik team
Oscar
Top achievements
Rank 1
Poul Henningsen
Top achievements
Rank 1
Share this question
or