Switch active tab from code-behind: sometimes OK, sometimes KO...

6 posts, 0 answers
  1. Philippe
    Philippe avatar
    8 posts
    Member since:
    Jun 2010

    Posted 03 Feb 2014 Link to this post


    Hello,

    I have a tabstrip with four tabs, linked to four pageviews.

    A button on the first tab (Basket), activates the second tab (Shipping).
    A button on the second tab (Shipping), activates the thirth tab (Payment).

    After a click on the first button, the code-behind is run, the properties of the tabstrip (SelectedIndex) and pageviews (enabled, selected) are OK, but nothing is updated on screen !
    After a click on the second button, everything runs fine and the thirth tab is activated and the thirth pageview is correctly displayed...

    I'm new to telerik controls, and such behaviour surprises me...

    Here my code-behind:

    protected void btnShipping_Click(object sender, EventArgs e)
    {
        // First first to second tab
        tabShipping.Enabled = true;
        tabShipping.Selected = true;
        pvShipping.Selected = true; // DOES NOT WORK. Nothing updates on screen...
    }

    protected void btnPayment_Click(object sender, EventArgs e)
    {
       // From second to thirth tab
       tabPayment.Enabled = true;
       tabPayment.Selected = true;
       pvPayment.Selected=true;            // Everything is OK...
    }

    Any idea ?
    Thank you in advance...

    Philippe
  2. Philippe
    Philippe avatar
    8 posts
    Member since:
    Jun 2010

    Posted 03 Feb 2014 in reply to Philippe Link to this post

    One more interesting information:

    If, on the thirth tab (Payment), I place a "Back to shipping" button that points to the SAME btnShipping_click function, the Shipping tab is correctly displayed on screen...

    The problem only exists when the event is fired from the first tab...

    Philippe
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Feb 2014 in reply to Philippe Link to this post

    Hi Philippe,

    Please have a look into the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1">
        <Tabs>
            <telerik:RadTab Text="Tab1" PageViewID="RadPageView1">
            </telerik:RadTab>
            <telerik:RadTab Text="Tab2" PageViewID="RadPageView2">
            </telerik:RadTab>
            <telerik:RadTab Text="Tab3" PageViewID="RadPageView3">
            </telerik:RadTab>
        </Tabs>
    </telerik:RadTabStrip>
    <telerik:RadMultiPage ID="RadMultiPage1" runat="server">
        <telerik:RadPageView ID="RadPageView1" runat="server">
            <telerik:RadButton ID="RadButton1" runat="server" Text="secondTab" OnClick="RadButton1_Click">
            </telerik:RadButton>
        </telerik:RadPageView>
        <telerik:RadPageView ID="RadPageView2" runat="server">
            <telerik:RadButton ID="RadButton2" runat="server" Text="ThirdTabb" OnClick="RadButton2_Click">
            </telerik:RadButton>
        </telerik:RadPageView>
        <telerik:RadPageView ID="RadPageView3" runat="server">
            <telerik:RadButton ID="RadButton3" runat="server" Text="FirstTab" OnClick="RadButton3_Click">
            </telerik:RadButton>
        </telerik:RadPageView>
    </telerik:RadMultiPage>

    C#:
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        RadTab tab = RadTabStrip1.FindTabByText("Tab2");
        tab.Selected = true;
        RadPageView page = (RadPageView)tab.PageView;
        page.Selected = true;
    }
    protected void RadButton2_Click(object sender, EventArgs e)
    {
        RadTab tab = RadTabStrip1.FindTabByText("Tab3");
        tab.Selected = true;
        RadPageView page = (RadPageView)tab.PageView;
        page.Selected = true;
    }
    protected void RadButton3_Click(object sender, EventArgs e)
    {
        RadTab tab = RadTabStrip1.FindTabByText("Tab1");
        tab.Selected = true;
        RadPageView page = (RadPageView)tab.PageView;
        page.Selected = true;
    }

    Let me know if you have any concern.
    Thanks,
    Shinu.
  5. Philippe
    Philippe avatar
    8 posts
    Member since:
    Jun 2010

    Posted 03 Feb 2014 in reply to Shinu Link to this post

    Hi Shinu,

    Thank you for your quick answer.
    Your code also runs fine at my side...
    I have to find what disturbs this normal behaviour...
    If I find something, I will post it.
    Thanks again.

    Philippe
  6. Philippe
    Philippe avatar
    8 posts
    Member since:
    Jun 2010

    Posted 03 Feb 2014 in reply to Philippe Link to this post

    Origin of the problem found: my button was within a "RadAjaxPanel".
    I removed it and eveything runs as expected...
    Strange...
    Any idea why ?

    Philippe
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Feb 2014 in reply to Philippe Link to this post

    Hi Philippe,

    The RadAjaxPanel control provides the easiest way to AJAX-enable ASP.NET web control. To do this you simply need to place the controls that you want ajaxified into RadAjaxPanel and Telerik RadAjax takes care of the rest. The controls inside the RadAjaxPanel will start performing callbacks instead of postbacks and the whole RadAjaxPanel is updated when one of the controls makes an AJAX request.There are cases when you may want to update the information inside the panel by triggering a callback externally from other control on the page. You need to make a call to the $find(<%RadAjaxPanel1.ClientID%>).ajaxRequest() method and then override the RaisePostBackEvent method or handle the RadAjaxPanel AjaxRequest server-side event to apply the changes. Please have a look into this help documentation for further information about RadAjaxPanel.

    Hope this will helps you.
    Thanks,
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017