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

$find("<%=RadTabStrip.ClientID %>") is returning NULL

2 Answers 332 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 01 Feb 2010, 05:35 PM
I have a web control with a RadTabStrip, and when I call $find(), I'm getting NULL.  I know I must be doing something wrong, but for the life of me I don't know what.  Currently, I have both the RadTabStrip markup and the javascript that is calling $find() in the same .ascx file, and it's still not working.

Any ideas where I am going wrong?

<div runat="server"
    <telerik:RadTabStrip ID="radTabStrip" runat="server" Skin="Sunset" 
            MultiPageID="mpageTabs" SelectedIndex="0"
        <Tabs> 
            <telerik:RadTab Text="Graph"></telerik:RadTab> 
            <telerik:RadTab Text="Table"></telerik:RadTab> 
            <telerik:RadTab Text="Criteria"></telerik:RadTab> 
        </Tabs> 
    </telerik:RadTabStrip> 
    <telerik:RadMultiPage ID="mpageTabs" runat="server" SelectedIndex="0"
        <telerik:RadPageView ID="pageGraph" runat="server"
        </telerik:RadPageView> 
 
        <telerik:RadPageView ID="pageChart" runat="server"
        </telerik:RadPageView> 
 
        <telerik:RadPageView ID="pageCriteria" runat="server"
        </telerik:RadPageView> 
         
    </telerik:RadMultiPage> 
 
</div> 
 
<script type="text/javascript"
    function getRadTabStrip() 
    { 
        debugger; 
        var clientId = "<%= radTabStrip.ClientID %>"
        var tabStrip = $find(clientId); 
        return tabStrip; 
    } 
</script> 
 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Feb 2010, 06:28 AM
Hi Jeff,

It just works fine when I tried in my end (when calling the event handler from client only). I guess you are calling the client method from code behind, if so you could use the following code to invoke the client method.

CS:
 
protected void Button2_Click(object sender, EventArgs e) 
    { 
        ScriptManager.RegisterStartupScript(thisthis.GetType(), "key""<script type='text/javascript'>  function f(){getRadTabStrip()} Sys.Application.add_load(f); </script>"false);  // Call the client event handler 
    } 

JavaScript:
 
<script type="text/javascript">  
    function getRadTabStrip()  
    { 
        var clientId = "<%= radTabStrip.ClientID %>";  
        var tabStrip = $find(clientId);  
    }  
</script>  

-Shinu.
0
Jeff
Top achievements
Rank 1
answered on 02 Feb 2010, 03:30 PM
I'd been calling the client method from JQuery's $(document).ready(), which appears to be too early.  The client controller object didn't exist, yet.

What I was trying to do was to set the selected tab from a cookie, on page load.  I moved the code into an OnClientLoad event, and everything is working fine.
Tags
TabStrip
Asked by
Jeff
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jeff
Top achievements
Rank 1
Share this question
or