Telerik
Home / Community / Forums / RadControls for ASP.NET: Tabstrip / TabClick Event not fired

TabClick Event not fired

Feed from this thread
  • Jim Leyshon avatar

    Posted on Nov 25, 2007 (permalink)

    Why is the TabClick event not fired with AutoPostBack = true and follwing code

    // private void RadTabStrip1_TabClick(object sender, Telerik.WebControls.RadTabStripClickEventArgs e)

    private void RadTabStrip1_TabClick(object sender, Telerik.WebControls.TabStripEventArgs e)

    {

    // we'll want to see if this is a sub-tab before setting this.

    // currentSubTabID = e.ClickedTab.ID;

    // currentSubTabID = e.Tab.ID;

    // currentSubTabID = e.Tab.Value;

    currentSubTabID = ((DataRowView)e.Tab.DataItem)["navTabID"].ToString();

    }

    #region Web Form Designer generated code

    override protected void OnInit(EventArgs e)

    {

    //

    // CODEGEN: This call is required by the ASP.NET Web Form Designer.

    //

    InitializeComponent();

    base.OnInit(e);

    }

    /// <summary>

    /// Required method for Designer support - do not modify

    /// the contents of this method with the code editor.

    /// </summary>

    private void InitializeComponent()

    {

    // this.RadTabStrip1.TabClick += new Telerik.WebControls.RadTabStrip.RadTabStripTabClickEventHandler(this.RadTabStrip1_TabClick);

    this.RadTabStrip1.TabClick += new Telerik.WebControls.TabStripEventHandler(this.RadTabStrip1_TabClick);

    }

    #endregion

    Reply

  • Telerik Admin admin's avatar

    Posted on Nov 26, 2007 (permalink)

    Hello Jim Leyshon,

    The TabClick event won't fire if the NavigateUrl property of the tabs is set. Could that be the problem in your case?
    Otherwise your code looks OK and the TabClick event should have fired.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

    Reply

  • Jim Leyshon avatar

    Posted on Nov 27, 2007 (permalink)

    Albert,

    Yes, the NavigatURL property is set. But I also need to set the currentSubTabID field when the tab is clicked.

    Any suggestions on how to accomplish this?

    The TabClick event did fire with version 2 of the RadTabStrip even with the NavigateURL property set.

    Thanks,
    Steve

    Reply

  • Telerik Admin admin's avatar

    Posted on Nov 27, 2007 (permalink)

    Hello Jim Leyshon,

    You can store the value of the NavigateUrl property in the Value property of the tab. Then in the TabClick event you can use Response.Redirect to perform the actual navigation using the value property of the clicked tab:

    Response.Redirect(e.Tab.Value);

    Indeed RadTabStrip v2 used to first postback and then navigate but this required two roundtrips to the server which was not what users expected. That's why we decided to change that behavior.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

    Reply

  • Jim Leyshon avatar

    Posted on Jan 6, 2008 (permalink)

    Okay, now the main tabs generate the TabClick event but none of the sub tabs generate the tabclick event - how do I get the sub tabs to fire the event?

    Below is the data binding code with the tabstrip v2 code commented out:

    protected void RadTabStrip1_OnTabDataBound(object sender, TabStripEventArgs e)

    {

    Tab tabView = e.Tab;

    DataRowView drView = (DataRowView)e.Tab.DataItem;

    // if (!e.DataBoundDataRow.IsNull("tabWidth"))

    if (drView["tabWidth"].ToString() != string.Empty)

    {

    //e.DataBoundTab.Width = e.DataBoundDataRow["tabWidth"].ToString();

    tabView.Width =

    Unit.Parse(drView["tabWidth"].ToString());

    }

    else

    {

    // if there's no tab width in the database, use the default from the web.config file

    // e.DataBoundTab.Width = ConfigurationSettings.AppSettings["tabWidthDefault"];

    tabView.Width =

    Unit.Parse(ConfigurationSettings.AppSettings["tabWidthDefault"]);

    }

    if (drView["navigateURL"].ToString() != string.Empty)

    // if (!e.DataBoundDataRow.IsNull("navigateURL"))

    {

    // e.DataBoundTab.NavigateUrl = e.DataBoundDataRow["navigateURL"].ToString();

    // tabView.NavigateUrl = drView["navigateURL"].ToString();

    tabView.Value = drView[

    "navigateURL"].ToString();

    }

    if (pageNavTabID != string.Empty)

    {

    // If this tab is supposed to be the selected tab...

    // if (pageNavTabID == tabView.ID)

    if (pageNavTabID == drView["navTabID"].ToString())

    // if (pageNavTabID == e.DataBoundTab.ID)

    {

    if (drView["parentNavTabID"].ToString() != string.Empty)

    // if (e.DataBoundDataRow.IsNull("parentNavTabID"))

    {

    // If this tab has no parent, it's not a sub-tab and we can just select it.

    tabView.TabStrip.SelectedIndex = tabView.Index;

    // e.DataBoundTab.RadTabStrip.SelectedIndex = e.DataBoundTab.Index;

    }

    else

    {

    // Else we're working with a child tab (a sub-tab)

    // Walk through each main tab to see which one contains this child tab

    // foreach (Tab tab in RadTabStrip1.TabCollection)

    foreach (Tab tab in RadTabStrip1.Tabs)

    {

    if (tab.Tabs.Contains(tabView))

    // if (tab.TabCollection.Contains(e.DataBoundTab))

    {

    // If we found the tab that contains the child...

    // First, select the correct parent tab.

    RadTabStrip1.SelectedIndex = tab.Index;

    // Then select the sub-tab within that parent tab

    // tab.SelectedIndex = e.DataBoundTab.Index;

    tab.SelectedIndex = tabView.Index;

    // Set the current tab, so it'll be remembered next time the user goes to the parent tab

    // UserNavBar.currentSubTabID = e.DataBoundTab.ID;

    // UserNavBar.currentSubTabNavigateURL = e.DataBoundTab.NavigateUrl;

    //UserNavBar.currentSubTabID = tabView.ID;

    // UserNavBar.currentSubTabID = tabView.Value;

    UserNavBar.currentSubTabID = drView["navTabID"].ToString();

    // UserNavBar.currentSubTabNavigateURL = tabView.NavigateUrl;

    UserNavBar.currentSubTabNavigateURL = tabView.Value;

    }

    }

    }

    }

    }

    if (drView["parentNavTabID"].ToString() != string.Empty)

    // if (!e.DataBoundDataRow.IsNull("parentNavTabID"))

    {

    // e.DataBoundTab.ImageMiddleHoverDefault = "tabLeftDisabled.gif";

    // e.DataBoundTab.ImageHoverCenter = "tabLeftDisabled.gif";

    // e.DataBoundTab.ImageDefaultCenter = "tabLeftDisabled.gif";

    //tabView.ImageOverUrl = "tabLeftDisabled.gif";

    //tabView.ImageUrl = "tabLeftDisabled.gif";

    }

    if (drView["tabLabel"].ToString() != string.Empty)

    // if (!e.DataBoundDataRow.IsNull("tabLabel"))

    {

    tabView.Text = drView[

    "tabLabel"].ToString();

    // e.DataBoundTab.Text = e.DataBoundDataRow["tabLabel"].ToString();

    }

    if (drView["toolTip"].ToString() != string.Empty)

    // if (!e.DataBoundDataRow.IsNull("toolTip"))

    {

    // e.DataBoundTab.ToolTip = e.DataBoundDataRow["toolTip"].ToString();

    tabView.ToolTip = drView[

    "toolTip"].ToString();

    }

    }

    Reply

  • Telerik Admin admin's avatar

    Posted on Jan 7, 2008 (permalink)

    Hello Jim Leyshon,

    Please find attached a small project that demonstrates a hierarchical tabstrip. Clicking on a child tab is firing the server side TabClick event just fine.

    Please download it and give it a go.
    It will be very helpful for us if you can modify this project to reproduce the problem and send it back to us. You can attach the files to a new support thread.

    Regards,
    Veskoni
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
    Attached files

    Reply

Powered by Sitefinity ASP.NET CMS

Contact Us | Site Feedback | Terms of Use | Privacy Policy
Copyright © 2002-2009 Telerik. All rights reserved.