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

Submit behaviour when clicking tab

1 Answer 63 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
CabinetZulian
Top achievements
Rank 1
CabinetZulian asked on 28 Nov 2011, 09:56 PM
Hi,

We have a page with radtabstrip, and we're dynamically loading user controls when clicking on tabs.

In order to get the usercontrol state persists with viewstate, we reload them in in the page's onload event.

When we click on another tab than the selected one (let say tab index 0 => 2), we don't want to reload the tab 0's user control, but it's not possible as the TabClick event occurs after the Page's OnLoad one...

Is anyone have a solution ?

Best regards,

1 Answer, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 29 Nov 2011, 01:40 PM
Hi Cabinetzulian,

You can use the client  OnClientTabSelecting event to get the index of the selected tab. This event fires before any server-side events. You can store the index in a hiddnes field in the page, and then get it in the PageLoad event.
Here's an example:

<body>
    <form id="form1" runat="server">
    <asp:ScriptManager runat="server" />
    <script type="text/javascript">
    function TabSelecting(sender, args){
        var tab = args.get_tab();
        var index = tab.get_index();
        document.getElementById('hiddenField').value=index;    
    }
    </script>
    <div>
        <telerik:RadTabStrip ID="RadTabStrip1" runat="server"
            OnClientTabSelecting="TabSelecting"
            OnTabClick="RadTabStrip1_TabClick">
            <Tabs>
                <telerik:RadTab Text="tab1" />
                <telerik:RadTab Text="tab2" />
            </Tabs>
        </telerik:RadTabStrip>
        <asp:HiddenField ID="hiddenField" Value="0" runat="server" />
    </div>
    </form>
</body>

protected void Page_Load(object sender, EventArgs e)
{
    int tabIndex = Int32.Parse(hiddenField.Value);
}

Greetings,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
TabStrip
Asked by
CabinetZulian
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Share this question
or