This is a migrated thread and some comments may be shown as answers.
TabClick programmatically on buttonclick
5 Answers 110 Views
This is a migrated thread and some comments may be shown as answers.
Deepak Vasudevan
Top achievements
Rank 2
Deepak Vasudevan asked on 05 Dec 2011, 08:27 PM
I would like to have the TabClick event of the tabstrip invoked programmatically on button click. The button is in the first tab. When you click on the button in the first tab, it should enable the second tab, focus on the tab and do the actions outlined in tabclick like data binding. (All serverside)

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 06 Dec 2011, 05:51 AM
Hello,

Try the following code snippet.
CS:
void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)
 {
   RadTabStrip RadTabStrip1=sender as RadTabStrip;
   if (e.Tab.Text == "Tab 1")
   {
      RadTabStrip1.Tabs[1].Enabled = true;
   }
}

Thanks,
Princy.
0
Deepak Vasudevan
Top achievements
Rank 2
answered on 06 Dec 2011, 03:35 PM
Dear Princy,

RadTabStrip1.Tabs[1] is disabled. Will that if block e.Tab.Text would ever enter? Am I missing something?
0
Princy
Top achievements
Rank 1
answered on 07 Dec 2011, 05:46 AM
Hello,

The above code worked as expected on my end. Here is the full code.

CS:
protected void Page_Load(object sender, EventArgs e)
   {
      RadTabStrip RadTabStrip1 = new RadTabStrip();
      RadTab tab1 = new RadTab();
      tab1.Text = "Tab 1";
      RadTabStrip1.AutoPostBack = true;
      RadTab tab11 = new RadTab();
      tab11.Text = "Child 1";
      tab1.Tabs.Add(tab11);
      RadTab tab2 = new RadTab();
      tab2.Text = "Tab 2";
      tab2.Enabled = false;
      RadTabStrip1.Tabs.Add(tab1);
      RadTabStrip1.Tabs.Add(tab2);
      RadTabStrip1.TabClick += new RadTabStripEventHandler(RadTabStrip1_TabClick);
      form1.Controls.Add(RadTabStrip1);
   }
  void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)
   {
      RadTabStrip tabst=sender as RadTabStrip;
      if (e.Tab.Text == "Tab 1")
       {
          tabst.Tabs[1].Enabled = true;
       }
   }

Thanks,
Princy.
0
L
Top achievements
Rank 1
answered on 10 May 2013, 06:01 PM
HI, 

I'm having the same problem described at the beginning of this post. I have a RadTabStrip control that has two tabs. I want to invoke the OnTabClick event from a button inside the tab to change it to the other tab. The solution above does not solve my problem. Do you know something else I can do?

Here is my code

<telerik:RadTabStrip ID="RadTabStrip1" runat="server" SelectedIndex="0"
               MultiPageID="RadMultiPage1" OnTabClick="RadTabStrip1_OnTabClick">
                   <Tabs>
                       <telerik:RadTab runat="server" ID="radTab1" PostBack="true" TabIndex="0"
                       Text="RadTab1" PageViewID="RadPageView1">
                       </telerik:RadTab>
                       <telerik:RadTab runat="server" ID="radTab2" PostBack="true" TabIndex="0"
                       Text="RadTab2" PageViewID="RadPageView2">
                       </telerik:RadTab>
                   </Tabs>
               </telerik:RadTabStrip>
               <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0">
                   <telerik:RadPageView ID="RadPageView1" runat="server" Selected="true">
                        
                   </telerik:RadPageView>
                   <telerik:RadPageView ID="RadPageView2" runat="server">
                                                     
                               <asp:LinkButton ID="linkButton1"
                                   runat="server" Text="LinkButton1"
                                   OnClick="linkButton1_Click" />
                            
                   </telerik:RadPageView>
               </telerik:RadMultiPage>

Here is the linkButton1_Click event:
protected void linkButton1_OnClick(object sender, EventArgs e)
{
RadTabStrip1.Tabs[0].Enabled = true;
RadTabStrip1.SelectedIndex = 0;
RadMultiPage1.SelectedIndex = 0;
RadPageView1.Selected = true;
RadPageView2.Selected = false;
}

Thanks in advance,

0
Genady Sergeev
Telerik team
answered on 14 May 2013, 02:35 PM
Hello,

I've tried your code, however, it seems to work pretty fine. Perhaps there is an issue with the version of Telerik.Web.UI that you are using. Can you please give  it a try with a more recent version?

Alternatively, you can try the following syntax:

protected void linkButton1_OnClick(object sender, EventArgs e)
{
    RadTabStrip1.Tabs[0].Selected = true;
    RadTabStrip1.Tabs[0].PageView.Selected = true;
}

Kind regards,
Genady Sergeev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Asked by
Deepak Vasudevan
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 1
Deepak Vasudevan
Top achievements
Rank 2
L
Top achievements
Rank 1
Genady Sergeev
Telerik team
Share this question
or