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

RadTabStrip (elegant way to) prevent change tab on server side

3 Answers 61 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 03 Mar 2014, 05:39 PM
How server code can prevent tab change in an scenario as linked sample?

sample: http://www.telerik.com/help/aspnet-ajax/tabstrip-multipage-integrate-with-tabstrip.html

I know than I can handle tabclick in this way:

protected void  RadTabStrip1_handling_tabclick(object sender, EventArgs e) 
{  
  RadTabStrip1.Tabs[0].Selected = true;    
  RadTabStrip1.Tabs[0].PageView.Selected = true;


But it seems a little dirty. I would like a kind of canceled radgrid event member for radtabstrip event:

protected void linkButton1_OnClick(object sender, EventArgs e){  
   e.canceled  = true;
}

someone know a more elegant way to prevent change tab? 



 





3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 04 Mar 2014, 10:46 AM
Hi Daniel,

Please have a look into this forum thread which discuss about the same scenario.

Thanks,
Shinu.
0
Daniel
Top achievements
Rank 1
answered on 04 Mar 2014, 11:01 AM
Hello Mr Shinu,

thanks about your post. As I explain in subject, I need a solution on server side.

regards.
0
Shinu
Top achievements
Rank 1
answered on 05 Mar 2014, 04:10 AM
Hi Daniel,

As a work around please try the following code snippet which works fine at my end.

ASPX:
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" OnClientTabUnSelected="OnClientTabUnSelected1" OnTabClick="RadTabStrip1_TabClick">
    <Tabs>
        <telerik:RadTab Text="Tab1">
        </telerik:RadTab>
        <telerik:RadTab Text="Tab2">
        </telerik:RadTab>
        <telerik:RadTab Text="Tab3">
        </telerik:RadTab>
    </Tabs>
</telerik:RadTabStrip>
<asp:HiddenField ID="HiddenField1" runat="server" />

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

C#:
protected void RadTabStrip1_TabClick(object sender, Telerik.Web.UI.RadTabStripEventArgs e)
{
    if (e.Tab.Text == "Tab2") //check your condition
    {
        RadTab tab = (RadTab)RadTabStrip1.FindTabByText(HiddenField1.Value);
        tab.Selected = true;
    }
}

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