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

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

5 Answers 632 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Philippe
Top achievements
Rank 1
Philippe asked on 03 Feb 2014, 09:26 AM

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

5 Answers, 1 is accepted

Sort by
0
Philippe
Top achievements
Rank 1
answered on 03 Feb 2014, 09:59 AM
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
0
Shinu
Top achievements
Rank 2
answered on 03 Feb 2014, 11:39 AM
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.
0
Philippe
Top achievements
Rank 1
answered on 03 Feb 2014, 12:03 PM
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
0
Philippe
Top achievements
Rank 1
answered on 03 Feb 2014, 12:09 PM
Origin of the problem found: my button was within a "RadAjaxPanel".
I removed it and eveything runs as expected...
Strange...
Any idea why ?

Philippe
0
Shinu
Top achievements
Rank 2
answered on 04 Feb 2014, 04:25 AM
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.
Tags
TabStrip
Asked by
Philippe
Top achievements
Rank 1
Answers by
Philippe
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or