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

saving data when clicking on tabs

3 Answers 47 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
MBEN
Top achievements
Rank 1
Veteran
MBEN asked on 21 Nov 2013, 11:32 PM
I have a radtabstrip which i use as a wizard.
I have previous and next buttons implemented to move to and fro tabs.
I also let the user to move between the tabs by clicking the tabs.

On the previous/next buttons i save some data and update a datatable.
I need to implement the same when moving between the tabs.

I can subscribe to the TabClick event but I don't know how to update the data on the particular tab I moved out from?
Any help?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 25 Nov 2013, 10:04 AM
Hi MBEN,

Please have a look into the following code snippet to access the previously selected RadTab on OnTabClick event of RadTabStrip.

ASPX:
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" OnClientTabSelecting="OnClientTabSelecting1"
    AutoPostBack="true" OnTabClick="RadTabStrip1_TabClick">
    <Tabs>
        <telerik:RadTab Text="Tab1" runat="server">
        </telerik:RadTab>
        <telerik:RadTab Text="Tab2">
        </telerik:RadTab>
    </Tabs>
</telerik:RadTabStrip>
<asp:HiddenField ID="HiddenField1" runat="server" />

JavaScript:
<script type="text/javascript">
    function OnClientTabSelecting1(sender, args) {
        if (args.get_tab()._getPreviousVisibileTab() != null) {
            var hidden = document.getElementById("HiddenField1");
            hidden.value = args.get_tab()._getPreviousVisibileTab().tab.get_text()
        }
    }
</script>

C#:
protected void RadTabStrip1_TabClick(object sender, Telerik.Web.UI.RadTabStripEventArgs e)
{
    RadTab tab = (RadTab)RadTabStrip1.FindTabByText(HiddenField1.Value);
    //your code for Update the previously selected tab
}

Thanks,
Shinu.
0
MBEN
Top achievements
Rank 1
Veteran
answered on 25 Nov 2013, 06:01 PM
Hi Shinu,

I have grids inside my tabs and i perform client side validations on the grid and then save the grid data into datatable.
I do that in the usercontrol page for each grid.
How can i get access to all those controls and functionality on the page where my tabstrip is defined?
0
Shinu
Top achievements
Rank 1
answered on 26 Nov 2013, 05:23 AM
Hi MBEN,

I guess you want to access the RadGrid inside the UserControl Page in OnTabClick event of RadTabStrip in ASPX page. Please have a look into the following code snippet.

ASPX:
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1"
    OnClientTabSelecting="OnClientTabSelecting1" AutoPostBack="True" OnTabClick="RadTabStrip1_TabClick">
    <Tabs>
        <telerik:RadTab Text="Tab1" runat="server" PageViewID="RadPageView1">
        </telerik:RadTab>
        <telerik:RadTab Text="Tab2" runat="server" PageViewID="RadPageView2">
        </telerik:RadTab>
    </Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage ID="RadMultiPage1" runat="server">
    <telerik:RadPageView ID="RadPageView1" runat="server">
        <uc1:Grid ID="Grid1" runat="server" />
    </telerik:RadPageView>
    <telerik:RadPageView ID="RadPageView2" runat="server">
        Tab2
    </telerik:RadPageView>
</telerik:RadMultiPage>

C#:
protected void RadTabStrip1_TabClick(object sender, Telerik.Web.UI.RadTabStripEventArgs e)
{
    RadTab tab = (RadTab)RadTabStrip1.FindTabByText(HiddenField1.Value);
    if (tab != null)
    {
        if (tab.Text == "Tab1")
        {
            //accessing the usercontrol page of tab1
            UserControl control = (UserControl)RadMultiPage1.FindPageViewByID("RadPageView1").FindControl("Grid1");
            //accessing the radgrid from the usercontrol page
            RadGrid grid = (RadGrid)control.FindControl("RadGrid1");
        }
    }
}

Thanks,
Shinu.
Tags
TabStrip
Asked by
MBEN
Top achievements
Rank 1
Veteran
Answers by
Shinu
Top achievements
Rank 1
MBEN
Top achievements
Rank 1
Veteran
Share this question
or