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

2 posts, 0 answers
  1. Shawn
    Shawn avatar
    30 posts
    Member since:
    Jun 2014

    Posted 09 May Link to this post

    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.

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    834 posts

    Posted 12 May Link to this post

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