saving data when clicking on tabs

4 posts, 0 answers
  1. MBEN
    MBEN avatar
    159 posts
    Member since:
    Nov 2011

    Posted 21 Nov 2013 Link to this post

    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?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Nov 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. MBEN
    MBEN avatar
    159 posts
    Member since:
    Nov 2011

    Posted 25 Nov 2013 Link to this post

    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?
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Nov 2013 Link to this post

    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.
Back to Top