TabClick programmatically on buttonclick

6 posts, 0 answers
  1. Deepak Vasudevan
    Deepak Vasudevan avatar
    82 posts
    Member since:
    May 2010

    Posted 05 Dec 2011 Link to this post

    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)
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Dec 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Deepak Vasudevan
    Deepak Vasudevan avatar
    82 posts
    Member since:
    May 2010

    Posted 06 Dec 2011 Link to this post

    Dear Princy,

    RadTabStrip1.Tabs[1] is disabled. Will that if block e.Tab.Text would ever enter? Am I missing something?
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Dec 2011 Link to this post

    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.
  6. L
    L avatar
    29 posts
    Member since:
    Mar 2012

    Posted 10 May 2013 Link to this post

    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,

  7. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 14 May 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017