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

Client-side reference to RadTabStrip

3 Answers 137 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Shed Dweller
Top achievements
Rank 1
Shed Dweller asked on 22 Jul 2008, 03:52 PM
Basically I just want to set a tab on a RadTabStrip to be selected but I seem to be falling at the first fence.

According to the documentation 
http://www.telerik.com/help/aspnet-ajax/tab_clientsideradtab.html
you can use this syntax...

var tabStrip = $find("<%=RadTabStrip1.ClientID%>");

Unfortunately no matter where I put this bit of code it always returns null.

I've been trying to do this for about 3 hours now and it's driving me nuts.

I've also tried 

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

Which only returns a value if placed after the definition of the RadTabStrip, as you might expect.  However it doesn't have any of the published client-side methods associated with it.

Baffled.

------------------------------

Created a very simple page with virtual nothing in it - still doesn't work....

<body>
    <form id="form1" runat="server">
      
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <telerik:RadTabStrip ID="RadTabStrip1" runat="server">
            <Tabs>
                <telerik:RadTab runat="server" Text="Tab1">
                </telerik:RadTab>
                <telerik:RadTab runat="server" Text="Tab2">
                </telerik:RadTab>
            </Tabs>
        </telerik:RadTabStrip>
    <div>
   
    </div>
    </form>
   
    <script type="text/javascript" >
               
        var tabStrip = $find("<%= RadTabStrip1.ClientID %>");     
        if(tabStrip == null)
            alert("bad");
       
        </script>
</body>

3 Answers, 1 is accepted

Sort by
0
Sean
Top achievements
Rank 2
answered on 22 Jul 2008, 11:00 PM
Hi Sean,

I feel your pain. I always have issues trying to get the sample code to work. *Shrug* I normally have to find a workaround.

The first thing I would try is to use a '#' instead of the '=' in your code block. That sometimes plays havoc in ASP.net.

You may also try to use $get instead of $find. $find is not in .NET, I don't think. Prototype maybe? I might be wrong though as I am not up on my scripts.

I did this as a solution for a project:
function TabChanged(t)  
{  
    var tab = $get('RadTab1');  
    tab.tabIndex = t;  
    tab.tabclick();  

I believe that there is also a selectedIndex property on the tab. I.e. tab.selectedIndex = value.

Sean
0
Shed Dweller
Top achievements
Rank 1
answered on 23 Jul 2008, 07:34 AM

Thanks Sean

I actually found a solution yesteday.  I realised that the $find() command doesn't work as the page is loading.  You have to wait until the page is fully loaded first before you can call it.

What I did was to wrap the getting of the reference into a function like this...

                                    
function GetTabStrip()
{  
    return $find("<%=RadTabStrip1.ClientID%>");               
}  











Then in my client event handler I can do things like...
var tab = GetTabStrip().findTabByAttribute( "TabID", strTabID );



Sean

0
Accepted
Paul
Telerik team
answered on 23 Jul 2008, 08:23 AM
Hi Sean,

Please refer to this forum post for details on the matter.

Regards,
Paul
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TabStrip
Asked by
Shed Dweller
Top achievements
Rank 1
Answers by
Sean
Top achievements
Rank 2
Shed Dweller
Top achievements
Rank 1
Paul
Telerik team
Share this question
or