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

Tab Cancel After PostBack

2 Answers 98 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Bobby
Top achievements
Rank 1
Bobby asked on 07 Jan 2009, 04:46 PM
Scenario:
Each tab corresponds to a certain user control, so all of the pageviews are dynamically loaded when the tab is clicked.  The page that contains the TabStrip has a navigation buttons and the Save/Cancel buttons.  The Save/Cancel buttons have the appropriate logic to to actually call into the user controls and save their data.  The navigation (Previous/Continue) buttons are used to navigate the TabStrip.

If there is data that hasn't been saved, and the user clicks a new tab, or one of the navigation buttons, a client side alert is shown and prompts the user to save, or lose their changes.  If the user clicks to save their data, the tab selecting client side function cancels the event and calls the Save button's server side event via __doPostBack.

Issue:
When the data is saved, and no error has occurred, I need to continue to the appropriate tab that was clicked, or the next sequential tab depending on the navigation button.  If an error has occurred, then the user should remain on that tab to fix any changes.

Is there a way to select a particular tab from my Button_Click server side event, if the save is successful?



2 Answers, 1 is accepted

Sort by
0
Antony
Top achievements
Rank 1
answered on 13 Mar 2009, 08:46 AM
We have a similiar requirement, is there onyone who could set up an example of how to do this?

Many thanks
Antony
0
Paul
Telerik team
answered on 13 Mar 2009, 02:31 PM
Hi Antony,

RadTabStrip has a number of useful methods for accessing the tabs in the tab strip - FindTabByText, FindTabByUrl, FindTabByValue.

You can select the needed tab server-side by it's index, text or value. Another option is to directly set the tabstrip SelectedIndex property to the needed tab Index.

protected void Button1_Click(object sender, EventArgs e)  
    {  
        RadTabStrip1.SelectedIndex = 1;  
    } 

or

    protected void Button1_Click(object sender, EventArgs e)  
    {  
        if (RadTabStrip1.SelectedTab != null)  
        {  
            RadTabStrip1.SelectedIndex = RadTabStrip1.SelectedTab.Index + 1;  
        }  
        else 
        {  
            RadTabStrip1.SelectedIndex = 0;  
        }  
    } 

or

    protected void Button1_Click(object sender, EventArgs e)  
    {  
        RadTab myTab = (RadTab)RadTabStrip1.FindTabByText("Root RadTab2");  
        myTab.Selected = true;  
        myTab.SelectParents();  
    } 

For details on the matter please take a look at this example.

Sincerely yours,
Paul
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
TabStrip
Asked by
Bobby
Top achievements
Rank 1
Answers by
Antony
Top achievements
Rank 1
Paul
Telerik team
Share this question
or