Autopostback not firing on TabStrip with Multipage

2 posts, 0 answers
  1. Shuja
    Shuja avatar
    30 posts
    Member since:
    Mar 2011

    Posted 18 Feb 2013 Link to this post

    Hi,

    I've implemented a load-on-demand radtabstrip with radmultipage using the telerik demo. This works fine. Each tab shows an ascx control which holds a different Radgrid.
    I then tried to implement the RenderSelectedPageOnly by setting this to "true" & setting AutoPostBack to "true" on the TabStrip.
    However, this did not work. When i load my page, the default tab loads & when i click on to another tab then this loads correctly.
    BUT if i click back on to a tab i already viewed, it displays a blank tab with no radgrid. I tried to trace the AutoPostBack but it does not seem to be firing.
    All i want to do is render the selected page of the TabStrip but when another tab is selected (regardless of whether it has been rendered before) load the newly clicked Tabs page contents.
    My code is as follows:

    HTML:
    <telerik:RadTabStrip OnClientTabSelecting="onTabSelecting"     ID="RadTabStrip1" SelectedIndex="0"       runat="server" MultiPageID="RadMultiPage1"
        OnTabClick="RadTabStrip1_TabClick" Width="900px" AutoPostBack="true" >
    </telerik:RadTabStrip>
     
    <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0" OnPageViewCreated="RadMultiPage1_PageViewCreated" Width="900px" RenderSelectedPageOnly="true" >
    </telerik:RadMultiPage>


    JAVASCRIPT:
    function onTabSelecting(sender, args) {
        if (args.get_tab().get_pageViewID()) {
            args.get_tab().set_postBack(false);
        }
    }

    .CS
    protected void Page_Load(object sender, EventArgs e)
    {      
         if (!Page.IsPostBack)
        {
            AddTab("MyForms");
            AddPageView(RadTabStrip1.FindTabByText("MyForms"));
            AddTab("MyApprovals");
            AddTab("MySystemsApprovals");
            AddTab("MyGateKeeperApprovals");
        }
    }
     
    private void AddTab(string tabName)
    {
        RadTab tab = new RadTab();
        tab.Text = tabName;
        RadTabStrip1.Tabs.Add(tab);
    }
     
    private void AddPageView(RadTab tab)
    {
        RadPageView pageView = new RadPageView();
        pageView.ID = tab.Text;
        RadMultiPage1.PageViews.Add(pageView);
        pageView.CssClass = "pageView";
        tab.PageViewID = pageView.ID;
    }
     
    protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)
    {
        AddPageView(e.Tab);
        e.Tab.PageView.Selected = true;
    }
     
    protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
    {
        string userControlName = e.PageView.ID + "CS.ascx";
     
        Control userControl = Page.LoadControl(userControlName);
        userControl.ID = e.PageView.ID + "_userControl";
     
        e.PageView.Controls.Add(userControl);
    }

    Can anyone tell me what i'm doing wrong or why the autopostback is not firing when a viewed tab is selected again?
    Is there a different way of getting the TabStrip to render selected page only but reload a different tab when clicked on?

    Regards,

    Shuja



  2. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 21 Feb 2013 Link to this post

    Hello Shuja,

    The intention of the Load On Demand functionality, regarding the RadTabStrip control is to omit the PostBack, when certain Tab and the corresponding PageView has already been selected. In other word,
    to omit the request to the server to load PageViews, which have already been loaded. This is achieved with the functionality in the onTabSelecting function. When the RenderSelectedPageOnly is set you are obligated to fire a PostBack, since the html which is about to be rendered should be extracted from the server. This is the reason why, when you click to a Tab, which previously had been selected, the PageView is not loaded.

    I have two suggestions for overcoming the faced issue. You could either remove the RenderSelectedPageOnly property from the declaration of the RadMultiPage control or remove the  onTabSelecting function and fire a PostBack each time certain RadTab is clicked. Using the second approach, you won't be able to take advantage of the Load On Demand functionality, because of the requests that needs to be fired to the server each time when clicking on a RadTab.

    In addition, please note that the dll files from the sample are removed.

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