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

Problem with OnTabClick

4 Answers 220 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Lucas Bailey
Top achievements
Rank 1
Lucas Bailey asked on 29 Apr 2009, 07:25 PM

I have a RadTabStrip control.  I create the tabs dynamically by binding a DataTable.  The Datatable has four columns: ID, Name, URL, and ParentID.  When a tab is clicked, it redirects to the page specified by the URL.

I want to add some functionality before the redirect.  When I add an addtabclick property to the RadTabStrip, nothing happens.  There is also no Postback on the page the click occurs on.

 

What am I missing?

4 Answers, 1 is accepted

Sort by
0
prismcarlson
Top achievements
Rank 1
answered on 29 Apr 2009, 07:40 PM
Code would be helpful, but I believe what you are missing is ClickSelectedTab="True" in the RadTabStrip declaration. 
0
Lucas Bailey
Top achievements
Rank 1
answered on 29 Apr 2009, 07:48 PM
That didn't work.  So here's my code.

<telerik:RadTabStrip ID="rts_Tabs0" runat="server" DataNavigateUrlField="URL"   
        DataTextField="Name" DataValueField="ID" DataFieldID="ID" 
    DataFieldParentID="ParentID" CausesValidation="false" Skin="CCI" EnableEmbeddedSkins="false" ontabclick="RadTabStrip1_TabClick" ClickSelectedTab="true"></telerik:RadTabStrip> 

And my bind code

protected void BindTabs()  
    {  
        IList<ProviderCategory> topLevelCategories = CCIPage.ObjectModel.CategoryFactory.GetAllProviderCategories(false, true);  
        IList<ProviderCategoryWrapper> topLevelTabs = new List<ProviderCategoryWrapper>();  
        RadTab tab;  
        int topLevelCategoryCount = 0;  
 
        DataTable tabs = new DataTable();  
        tabs.Columns.Add(new DataColumn("ID", typeof(long)));  
        tabs.Columns.Add(new DataColumn("Name", typeof(string)));  
        tabs.Columns.Add(new DataColumn("ParentID", typeof(long)));  
        tabs.Columns.Add(new DataColumn("URL", typeof(string)));  
 
 
 
        foreach (ProviderCategory pc in topLevelCategories)  
        {  
            DataRow dr = tabs.NewRow();  
 
            dr["ID"] = pc.CategoryID;  
            dr["Name"] = pc.Category.Label;  
            dr["URL"] = "~/Client/Profile/" + pc.Category.StandardName + "Tab.aspx";  
 
            if (pc.Category.ParentCategory != null)  
                dr["ParentID"] = pc.Category.ParentCategory.ID;  
            else  
                dr["ParentID"] = System.DBNull.Value;  
 
            tabs.Rows.Add(dr);  
 
            if (pc.ParentProviderCategory == null)  
                topLevelCategoryCount++;  
        }  
 
        int breakPoint = 0;  
        if(topLevelCategoryCount > 9)  
            breakPointtopLevelCategoryCount / 2;  
 
        rts_Tabs0.DataSource = tabs;  
        rts_Tabs0.DataBind();  
 
        //set the tabindex to -1 so they are not a tab stop  
        for (var x = 0; x < rts_Tabs0.Tabs.Count(); x++)  
        {  
            rts_Tabs0.Tabs[x].TabIndex = -1;  
        }  
 
        if (breakPoint > 0)  
        {  
            tab = rts_Tabs0.Tabs[breakPoint - 1];  
            tab.IsBreak = true;  
        }  
 
        tab = rts_Tabs0.FindTabByUrl(Request.Url.PathAndQuery);  
        if (tab != null)  
            tab.SelectParents();  
    } 
0
Atanas Korchev
Telerik team
answered on 01 May 2009, 12:11 PM
Hello,

This is by design. When you set the NavigateUrl property of a tab the TabClick event does not fire for that tab. If you need to first postback then redirect you should avoid setting the NavigateUrl property. You can store it in the Value property or use a custom attribute (to do this you need to subscribe to the TabDataBound event). Then in your TabClick event you can use Response.Redirect to perform the navigation.

Regards,
Albert
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Lucas Bailey
Top achievements
Rank 1
answered on 01 May 2009, 04:39 PM
I figured it was something like that.  The work-around works like a charm. Thanks
Tags
TabStrip
Asked by
Lucas Bailey
Top achievements
Rank 1
Answers by
prismcarlson
Top achievements
Rank 1
Lucas Bailey
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or