Can't get client-side tabstrip.enable() to work

5 posts, 0 answers
  1. FU
    FU avatar
    24 posts
    Member since:
    Jul 2006

    Posted 16 May 2008 Link to this post

    To prevent users from clicking a tab before the page is loaded I disable the tabstrip serverside:

    myTab.Enabled =

    false;

    and then enable it client-side:
    <script type="text/javascript" language="javascript">

    function EnableTabStrip()

    {

        var tabStrip = <%= myTab.ClientID %>;

        tabStrip.enable();

    }

    </script>

    <body onload="EnableTabStrip();">

    but this doesn't work. It seems I get the object but it receive an 'Object doesn't support this property or method'-error. I tried to change
    var tabStrip = <%= myTab.ClientID %>;

    to:

    var tabStrip = $find('<%= myTab.ClientID %>');

    but this gives me a 'null' is null or not an object-error

    What am I doing wrong? I am using the latest build (2008.1 515)

  2. Paul
    Admin
    Paul avatar
    4281 posts

    Posted 16 May 2008 Link to this post

    Hi Mickey13,

    Please find below a sample code snippet that shows the needed approach.

    ASPX:
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head id="Head1" runat="server">  
        <title>Untitled Page</title> 
        <link href="Skins/WebBlue/Upload.WebBlue.css" rel="stylesheet" type="text/css" /> 
    </head> 
    <body> 
        <form id="form1" runat="server">  
            <asp:ScriptManager ID="ScriptManager1" runat="server">  
            </asp:ScriptManager> 
     
            <script type="text/javascript">  
            function pageLoad()  
            {  
                var myTabstrip = $find("<%= RadTabStrip1.ClientID %>");  
                myTabstrip.enable();  
            }  
            </script> 
     
            <telerik:RadTabStrip ID="RadTabStrip1" runat="server" OnTabClick="RadTabStrip1_TabClick">  
                <Tabs> 
                    <telerik:RadTab runat="server" Text="Root RadTab1">  
                    </telerik:RadTab> 
                    <telerik:RadTab runat="server" Text="Root RadTab2">  
                    </telerik:RadTab> 
                    <telerik:RadTab runat="server" Text="Root RadTab3">  
                    </telerik:RadTab> 
                </Tabs> 
            </telerik:RadTabStrip> 
        </form> 
    </body> 
    </html> 
     

    Code-behind:
    protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)  
    {  
        RadTabStrip1.Enabled = false;  


    Sincerely yours,
    Paul
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. FU
    FU avatar
    24 posts
    Member since:
    Jul 2006

    Posted 16 May 2008 Link to this post

    I tried making a complete example which still gives me the 'null' is null or not an object-error:
    <%@ Page Language="C#" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Untitled Page</title>
    </head>
    <body onload="enableTabStrip();">
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <script type="text/javascript" language="javascript">
            function enableTabStrip()
            {
                var myTabStrip = $find("<%= RadTabStrip1.ClientID %>");
                myTabStrip.enable();
            }
            </script>         
            <telerik:RadTabStrip ID="RadTabStrip1" runat="server">
                <Tabs> 
                    <telerik:RadTab runat="server" Text="Root RadTab1" />  
                    <telerik:RadTab runat="server" Text="Root RadTab2" />
                    <telerik:RadTab runat="server" Text="Root RadTab3" />
                </Tabs> 
            </telerik:RadTabStrip> 
        </form>
    </body>
    </html>
  4. Paul
    Admin
    Paul avatar
    4281 posts

    Posted 16 May 2008 Link to this post

    Hello Mickey13,

    Here's your modified code snippet that works as expected.

    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head> 
        <title>Untitled Page</title> 
    </head> 
    <body> 
        <form id="form1" runat="server">  
            <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
            <script type="text/javascript" language="javascript">  
            function pageLoad()  
            {  
                var myTabStrip = $find("<%= RadTabStrip1.ClientID %>");  
                myTabStrip.enable();  
            }  
            </script>           
            <telerik:RadTabStrip ID="RadTabStrip1" runat="server" OnTabClick="RadTabStrip1_TabClick1">  
                <Tabs>   
                    <telerik:RadTab runat="server" Text="Root RadTab1" />    
                    <telerik:RadTab runat="server" Text="Root RadTab2" /> 
                    <telerik:RadTab runat="server" Text="Root RadTab3" /> 
                </Tabs>   
            </telerik:RadTabStrip>   
        </form> 
    </body> 
    </html>  

    pageLoad is a shortcut for the Sys.Application.load event. For details on the matter please refer to the following ASP.NET article.

    Best wishes,
    Paul
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. FU
    FU avatar
    24 posts
    Member since:
    Jul 2006

    Posted 19 May 2008 Link to this post

    That was exactly what I needed. Thank you.
Back to Top