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

Load User Control

1 Answer 109 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 08 Mar 2010, 02:00 PM
Hello,

I have an issue in regards to loading a user control.

I have a radtabstrip inside a header user control and each tab dynamically loads a user control into a content panel on the main page. The first tab loads a user control and inside that it has a button that loads another user control and replaces the current user control *which is itself* inside the content panel.

This is working fine as expected.

The issue I have is when I want to reload the orginial user control that the first tab loads it wont let me because I have already clicked  the first tab, the tabClick event wont fire a second time. So therefore I can't reload my first usercontrol back onto the page.

Is there anyway to force the TabClick to fire again when I click onto it a second time?

Mike

1 Answer, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 11 Mar 2010, 09:35 AM
Hi Michael,

Normally, RadTabStrip does not postback when you click on the selected tab. To override this behavior you need to modify one of the internal javascript functions of the control. Here is how - add the following javascript code after the TabStrip's declaration:

<script type="text/javascript">
Telerik.Web.UI.RadTab.prototype.select = function (e)
{  
    var parent = this.get_parent();
    if (!parent)
    {
        this._cachedSelected = true;
        return true;
    }
     
    var shouldNavigate = this._shouldNavigate();
    var selectedTab = parent.get_selectedTab();
    var tabStrip = this.get_tabStrip();
     
//these lines are commented so the tabstrip postbacks even if you click on the selected tab
//      if (!shouldNavigate && selectedTab == this && !tabStrip.get_clickSelectedTab())
//          return false;
         
    if (tabStrip._raiseCancelEvent("tabSelecting", this, e))
        return false;
 
    var suppressVisualUpdate = this._shouldPostBack() || (shouldNavigate && (!this.get_target() || this.get_target() == "_self"));
     
    if (!e)
        suppressVisualUpdate = false;
         
    if (selectedTab && selectedTab != this)
        selectedTab.unselect(suppressVisualUpdate, e);
         
    parent._setSelectedIndex(this.get_index());
    tabStrip._registerSelectedTab(this);
 
    if (!suppressVisualUpdate)
    {
        this._updateAppearance(true);
        this._updateSiblings(true);
        this._setChildListDisplay("");
         
        if (this._scroller)
        {
            this._scroller._showArrows();
        }
        else
        {
            tabStrip._scrollInitInProgress = true;
            this._initScrolling();
            tabStrip._scrollInitInProgress = false;
        }
        if (tabStrip._reorderTabsOnSelect)
            Telerik.Web.UI.RadTabStrip._reorderTabs(parent.get_childListElement(), this.get_element());
    }      
     
    if (tabStrip.get_multiPage())
        this._selectPageView(suppressVisualUpdate);
     
    tabStrip._raiseEvent("tabSelected", this, e);
    return true;
}
</script>
 
Hope this helps.

Kind regards,
Veskoni
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
TabStrip
Asked by
Michael
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or