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

4 posts, 0 answers
  1. Daniel
    Daniel avatar
    16 posts
    Member since:
    Jun 2013

    Posted 03 Mar 2014 Link to this post

    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? 



     





  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Mar 2014 in reply to Daniel Link to this post

    Hi Daniel,

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

    Thanks,
    Shinu.
  3. Daniel
    Daniel avatar
    16 posts
    Member since:
    Jun 2013

    Posted 04 Mar 2014 in reply to Shinu Link to this post

    Hello Mr Shinu,

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

    regards.
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Mar 2014 in reply to Daniel Link to this post

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