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

Browser Back Button Navigation for Dynamically Loaded User controls in a TabStrip

1 Answer 74 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 09 May 2016, 06:24 PM

Hello,

I have created an application that uses the TabStrip.  My application has a Master Page that loads the ASPX page containing the TabStrip.  I have  a RadScriptManager and a RadAjaxManager (EnableAJAX is set to 'true') in my MasterPage.  I've set the "EnableHistory" to "true" for the RadScriptManager, and when the user clicks on a Tab, within the TabClick event, I add a HistoryPoint that stores the Tab's "text" value.  Withing the "OnNavigate" event for the RadScriptManager I can find the TabStrip and MultiPage controls, and I can find the Tab from it's text.  However, when I set the "selected" property of the tab to 'true' nothing happens.  The tab does not get loaded.  What am I doing wrong?  Is there a better way to achieve browser's "Back-button" navigation for the TabStrip that's been ajaxified?

Sample Code:

OnNavigate event for the RadScriptManager:

protected void rsmSiteMaster_Navigate(object sender, HistoryEventArgs e)
{
    string backPage = Server.HtmlEncode(e.State["BackNavigation"]);
 
    ContentPlaceHolder cphTabStrip = (ContentPlaceHolder)Page.Master.FindControl("cphTabStrip");
    RadAjaxLoadingPanel alpTabStrip = (RadAjaxLoadingPanel)Page.Master.FindControl("alpTabStrip");
    RadTabStrip rtabstripTabs = (RadTabStrip)cphTabStrip.FindControl("rtabstripTabs");
    RadMultiPage rmpTabStrip = (RadMultiPage)cphTabStrip.FindControl("rmpTabStrip");
    RadTab tab = rtabstripTabs.FindTabByText(backPage);
    tab.Selected = true;
    tab.DataBind();
 
}

 

This is how I set the HistoryPoint withing the "TabClick" event:

string key = "BackNavigation";
RadScriptManager.GetCurrent(this).AddHistoryPoint(key, e.Tab.Text);

 

Thanks,

Shawn A.

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 12 May 2016, 01:50 PM
Hello Shawn,

When selecting a Tab through code, as in your rsmSiteMaster_Navigate handler, apart from setting the Tab's Selected property you have to set the associated PageView's Selected property as well. So if the Tab has an associated PageView with it, for example:
<telerik:RadTab runat="server" Text="RadTab1" PageViewID="RadPageView1">

you can select it the following way:
//...
tab.Selected = true;
tab.PageView.Selected = true;


Regards,
Ivan Danchev
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
TabStrip
Asked by
Shawn
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or